サーバーから通知を送信しようとすると、次のメッセージが表示されます。"Invalid token size"
このスレッドから、PushSharp は通知を送信しません。Sandbox証明書を運用サーバーに使用しようとしている、またはその逆が原因である可能性があることがわかりましたが、持っていないのでそうは思いません生産証明書のセットアップ。
次に、APNs 開発証明書 (.p12) をエクスポートし、それをサーバーで使用します (PushSharp の要求に応じて)。
.p12 ファイルを再度エクスポートして、証明書が実際のものであることを確認しましたが、うまくいきませんでした。
「サンドボックス」フラグも使用しています。
私が使用しているC#コードは次のとおりです。
static class APN
{
static PushBroker push = new PushBroker();
static byte[] appleCert = File.ReadAllBytes(@"C:\Certs\PineAppPushDev.p12");
static public void StartAPN()
{
Console.WriteLine("Starting APN ...");
/* Event listeners */
push.OnChannelException += broker_OnChannelException;
push.OnNotificationFailed += broker_OnNotificationFailed;
push.RegisterAppleService(new ApplePushChannelSettings(false, appleCert, "*****"));
}
static private void broker_OnChannelException(object sender, PushSharp.Core.IPushChannel pushChannel, System.Exception error)
{
Console.WriteLine("broker_OnChannelException:");
Console.WriteLine("PushChannel: " + pushChannel.ToString());
Console.WriteLine("Error: " + error.ToString());
}
static private void broker_OnNotificationFailed(object sender, PushSharp.Core.INotification notification, System.Exception error)
{
Console.WriteLine("broker_OnNotificationFailed:");
Console.WriteLine("Notification: " + notification.ToString());
Console.WriteLine("Error: " + error.ToString());
}
static public void SendAPN(string message, string deviceID)
{
Console.WriteLine("SendAPN");
Console.WriteLine("DeviceID: " + deviceID.ToString());
try
{
push.QueueNotification(new AppleNotification()
.ForDeviceToken(deviceID)
.WithAlert(message));
}
catch (Exception ex)
{
Console.WriteLine("ERROR: APN.SendAPN(): " + ex.ToString());
}
}
}
何が欠けているのかわからないので、どんな助けでも大歓迎です!