0

我从设备获取 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;
        }

更新:我从 pushmagic id 中删除了 '<'

4

1 回答 1

1

我建议首先从您的 mdm 消息中删除 V 形。

于 2012-06-11T13:40:31.957 回答