Pushsharp apple notification A call to SSPI failed error

与世无争的帅哥 提交于 2019-12-04 04:09:09

问题


I am using PushSharp to send Apple Push Notification in C# , i have my production .pem file and its password. Below is my code snippet.Am always getting this error ..

"A call to SSPI failed, see inner exception. ---> System.ComponentModel.Win32Exception: The message received was unexpected or badly formatted-" 

OR

"System.IO.IOException: Authentication failed because the remote party has closed the transport stream."

I tried almost all codes available in net.Even tried MoonAPNS but same error, For custom script also am getting this SSPI failure error. I use the same .pem file and run a php script to send push notification to APN from same server,it works.

var push = new PushBroker();
var appleCert = File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ck.pem"));
 push.RegisterAppleService(new ApplePushChannelSettings(false, appleCert, "pwd")); 
 push.QueueNotification(new AppleNotification()
                                           .ForDeviceToken("XXXXXXXXXXXXXXX")
                                           .WithAlert("Hello World!")
                                           .WithBadge(7)
                                           .WithSound("sound.caf"));


                LogManager.Info("Waiting for Queue to Finish..");
                push.StopAllServices();

Please help Thanks in advance


回答1:


I think your c# may be incorrect, To verify, rather than with a .pem, can you try with your p12 cert using the below code as a test...

    Boolean bsandbox = true;
    string p12fileName =AppDomain.CurrentDomain.BaseDirectory + "yourCert.p12";
    string p12password = "1234";

    string deviceID1 = "2909b25e0c699b2dc4864b4b9f719e67aac7e0fab791a72a086ffb788ba28f6a"; //
    string msg = "This is the message sent at : ";
    string alert = "Hello world at " + DateTime.Now.ToLongTimeString();
    int badge = 1;
    string soundstring = "default";
    var payload1 = new NotificationPayload(deviceID1, alert, badge, soundstring);
    payload1.AddCustom("custom1", msg); 

    var notificationList = new List<NotificationPayload> { payload1 };



    var push = new PushNotification(bsandbox, p12fileName, p12password);

    var rejected = push.SendToApple(notificationList);`


来源:https://stackoverflow.com/questions/18560980/pushsharp-apple-notification-a-call-to-sspi-failed-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!