Pushsharp 苹果通知 调用 SSPI 失败错误 [英] Pushsharp apple notification A call to SSPI failed error

查看:32
本文介绍了Pushsharp 苹果通知 调用 SSPI 失败错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 PushSharp 在 C# 中发送 Apple 推送通知,我有我的生产 .pem 文件及其密码.下面是我的代码片段.我总是收到这个错误..

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-" 

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

我尝试了网络中几乎所有可用的代码.甚至尝试过 MoonAPNS 但同样的错误,对于自定义脚本,也遇到此 SSPI 失败错误.我使用相同的 .pem 文件并运行一个 php 脚本从同一服务器向 APN 发送推送通知,它工作正常.

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();

请帮忙提前致谢

推荐答案

我认为您的 c# 可能不正确,为了验证,而不是使用 .pem,您可以使用以下代码作为测试尝试使用您的 p12 证书...

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);`

这篇关于Pushsharp 苹果通知 调用 SSPI 失败错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆