推送通知未发送至iPhone设备

时间:2012-06-11 13:06:46

标签: ios push-notification apple-push-notifications mdm

我从设备获取tokenUpdate,然后尝试发送推送通知。但我认为它不像我发送推送通知那样工作,我没有得到设备的任何响应。是不是要轮询服务器以检查是否有任何MDM命令?相反,我一直在接收令牌更新。

 String cToken = token;
            String cAlert = message;

            // Ready to create the push notification
            byte[] buf = new byte[256];
            MemoryStream ms = new MemoryStream();
            BinaryWriter bw = new BinaryWriter(ms);



            char[] tokenChars = token.ToCharArray();
            byte[] deviceTokenBytes = new byte[tokenChars.Length];
            for (int i=0; i < deviceTokenBytes.Length; i++)
            {
                deviceTokenBytes[i] = Convert.ToByte(tokenChars[i]);
            }

           // byte[] deviceToken = HexToData(cToken);
            bw.Write(deviceTokenBytes);


            // Create the APNS payload - new.caf is an audio file saved in the application bundle on the device
            //string msg = "{\"aps\":{\"alert\":\"" + cAlert + "\",\"badge\":" + iBadge.ToString() + ",\"sound\":\"new.caf\"}}";
            string msg = "{\"mdm\":\"+ mPushMagic +"\"}";

            // Write the data out to the stream
           // bw.Write((byte)msg.Length);
            bw.Write(msg.ToCharArray());
            bw.Flush();

            if (sslStream != null)
            {
                sslStream.Write(ms.ToArray());
                return true;
            }

            return false;
        }

更新:我删除了'&lt;'来自pushmagic id

1 个答案:

答案 0 :(得分:1)

我建议您从mdm消息中删除V形符号以开始。