PushSharp のバージョン 2.1.2 を使用しています。アプリは .NET 4.5.1 です (ただし、.NET 4.5 と .NET 4 もターゲットにしてみました)
サンドボックス Apple APNS を介してプッシュ メッセージを送信しようとしていますが、成功しません。
ここで提供されている Ray Wenderlich のウォークスルーで提供されている PHP スクリプトを使用して、同じ証明書を使用し、PushSharp アプリと同じデバイス ID に送信して、 メッセージを正常に送信しています。
完成した証明書をキー チェーンから p12 としてエクスポートしてテストしました。完成した証明書とキーをエクスポートしています。秘密鍵のエクスポート。こちらもこちらの方法で。PHP スクリプトで使用する証明書とキーを組み合わせると、問題はありません。
テストしたマシンにp12証明書をインポートしました-違いはないようです。
Apple プッシュ サービスをプッシュ ブローカーに登録するときに、IsProduction フラグを変更してみました。本番環境として設定してもエラーはありませんが (これはサンドボックス証明書ですが)、その場合も明らかにデバイスに到達しません。
私のメッセージはどれも通過せず、すべて次のようなサービス例外が発生します。
System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> System.ComponentModel.Win32Exception: The message received was unexpected or badly formatted
--- End of inner exception stack trace ---
at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at PushSharp.Apple.FeedbackService.Run(ApplePushChannelSettings settings, CancellationToken cancelToken)
at PushSharp.Apple.ApplePushService.<>c__DisplayClass4.<.ctor>b__1(Object state)
これは基本的に私のコードがどのように見えるかです:
var push = new PushBroker();
// register event handlers for channel create/destroy/exception, notificationrequeue, serviceexception, notification sent
var appleCert = File.ReadAllBytes(ConfigurationManager.AppSettings["CertAddress"]);
push.RegisterAppleService(new ApplePushChannelSettings(false, appleCert, ConfigurationManager.AppSettings["CertPassword"]));
var pn = new AppleNotification().ForDeviceToken(item.SendToDeviceIdentifier).WithAlert(item.AlertMessage).WithBadge(item.Badges);
push.QueueNotification(pn);
チャネルアップイベントが呼び出され、次にサービス例外が発生します。
関連する質問のいくつかは、このエラーがファイアウォールの問題に関連している可能性があると述べています.プッシュ通知を送信できる2つの異なるネットワークでアプリをテストしました(そのうちの1つは現在PushSharpアプリを使用しています).
どんな洞察も大歓迎です。