Search code examples
asp.netiosapple-push-notifications

failed send iOS push notification using Redth PushSharp


hello i'm developing a push notification service using Redth PushSharp library. I've been successfully able to send notification to my ipad from local pc. But when I upload it to my hosting service it occurs an exception!! See my code :

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

I got the PushNotification class from MoonApns PushNotification.cs.

When I send notification it gives the following error :

A call to SSPI failed.System.ComponentModel.Win32Exception (0x80004005): The message received was unexpected or badly formatted.

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

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

at PushNotification.SendQueueToapple(IEnumerable1 queue) in PushNotification.cs:line 121

at PushNotification.SendToApple(List1 queue) in PushNotification.cs:line 92

at PushNotificationIOS.SendPushNotification() in PushNotificationIOS.cs:line 48

Here is push service url : Test my Pushserivce Error

I'm using RackSpace Cloud Hosting

Anyone has any idea ??


Solution

  • Check this :

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

    Make the sandbox true !

    Check the cert too