我正在使用PushSharp在C#中发送苹果推送通知,我有生产环境的.pem文件和密码。以下是我的代码片段。我一直收到这个错误..
"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发送推送通知,它能够正常工作。
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