Pushsharp苹果通知调用到SSPI失败的错误 [英] Pushsharp apple notification A call to SSPI failed error
问题描述
,我有我的生产.pem文件和密码。下面是我的code snippet.Am总是收到此错误。
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."
我试过几乎所有codeS在net.Even可尝试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();
请帮忙
在此先感谢
Please help Thanks in advance
推荐答案
我觉得你的C#可能不正确,要进行验证,而不是用质子交换膜,你可以用你的P12尝试证书使用下面的code作为测试...
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屋!