【问题标题】:Pushsharp apple notification A call to SSPI failed errorPushsharp 苹果通知调用 SSPI 失败错误
【发布时间】:2013-09-04 20:10:06
【问题描述】:

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

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

请帮忙 提前致谢

【问题讨论】:

    标签: c# ios push-notification apple-push-notifications pushsharp


    【解决方案1】:

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

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

    【讨论】:

    • 是的,约翰...你是对的。它的 p12 文件用于 push sharp。我正在使用 pem 文件。使用 p12 文件解决了问题。谢谢
    • 我使用相同的代码推送,但出现异常:您选择了开发/沙盒(非生产)服务器,但您的证书似乎不是开发/沙盒证书!请检查以确保您拥有正确的证书!
    • @Legnus 您正在使用产品证书。
    • 是的,.p12 有效。我发现在我的案例中我必须使用密码才能使其工作。
    猜你喜欢
    • 2016-05-10
    • 1970-01-01
    • 1970-01-01
    • 2016-11-02
    • 1970-01-01
    • 2018-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多