【问题标题】:failed send iOS push notification using Redth PushSharp使用 Redth PushSharp 发送 iOS 推送通知失败
【发布时间】:2012-11-13 08:40:08
【问题描述】:

您好,我正在使用 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(布尔 authSucessCheck) 在 System.Net.Security.SslState.get_SecureStream()

在 System.Net.Security.SslStream.BeginRead(Byte[] buffer, Int32 offset, Int32 count, AsyncCallback asyncCallback, Object asyncState)

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

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

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

这里是推送服务地址:Test my Pushserivce Error

我正在使用RackSpace Cloud Hosting

有人知道吗??

【问题讨论】:

  • @CRDave 不!我不能!我为此使用了付费服务。

标签: asp.net ios apple-push-notifications


【解决方案1】:

检查一下:

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

让沙盒成为真实的!

也要检查证书

【讨论】:

    【解决方案2】:

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

    //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. 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-22
      相关资源
      最近更新 更多