0

您好,我正在使用Redth PushSharp库开发推送通知服务。我已经成功地能够从本地电脑向我的 ipad 发送通知。但是当我将它上传到我的托管服务时,它会发生异常!查看我的代码:

        Boolean bsandbox = true;
        string p12fileName =AppDomain.CurrentDomain.BaseDirectory + "CPDDevelopmentPushNotificationCertificate.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);` 

我从MoonApns PushNotification.cs获得了 PushNotification 类。

当我发送通知时,它会出现以下错误:

对 SSPI 的调用失败。System.ComponentModel.Win32Exception (0x80004005):收到的消息意外或格式错误。

System.Net.Security.SslState.CheckThrow(Boolean authSucessCheck) 在 System.Net.Security.SslState.get_SecureStream()

在 System.Net.Security.SslStream.BeginRead(字节 [] 缓冲区,Int32 偏移量,Int32 计数,AsyncCallback asyncCallback,对象 asyncState)

在 PushNotification.cs:line 121 中的 PushNotification.SendQueueToapple(IEnumerable1 queue)

在 PushNotification.cs:line 92 中的 PushNotification.SendToApple(List1 queue)

在 PushNotificationIOS.cs:line 48 中的 PushNotificationIOS.SendPushNotification()

这是推送服务网址:测试我的推送服务错误

我正在使用RackSpace 云托管

任何人有任何想法?

4

2 回答 2

0

重要提示:确保使用正确的推送证书。

//Make sure you upload the certificate with your project Develop or Production
//Make sure your path to certificate is correct
//I use a appsetting key/value  in web.config to save the name of push certificate 

var appleCert = File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, System.Configuration.ConfigurationManager.AppSettings["appleCert"]));


push.StartApplePushService(new ApplePushChannelSettings(false,appleCert, strYourPasswordCert));



push.QueueNotification(NotificationFactory.Apple()
                    .ForDeviceToken(IosIpadDeviceTocken)
                    .WithAlert(strTitle)
                    .WithSound("default")
                    .WithBadge(1)

                    );

push.StopAllServices(true);

//This code work for me. 
于 2012-11-30T17:38:37.367 回答
0

检查这个:

string deviceID1 = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    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);` 

让沙盒成为现实!

也检查证书

于 2013-04-30T19:31:15.337 回答