デバイスから 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 から「<」を削除しました