Search code examples
iosapple-push-notificationsapns-sharp

Apple Push Notifications Using Moon-APNS or APNS-Sharp


I am having really hard time figuring out how to send messages from my server to the APNS. I have used Moon-APNS and APNS-Sharp and I am stuck at the same error which is "parameter is incorrect". I generated the p12 file using KeyChain. I dragged the file into my Win 7 virtual environment and put it inside the bin\debug folder. Here is the code for Moon-APNS:

 static void Main(string[] args)
        {
            var deviceToken = "21212d6fefebde4d317cab41afff65631b5a4d47e5d85da305ec610b4013e616";

            var payload = new NotificationPayload(deviceToken, "hello world");
            var notificationList = new List<NotificationPayload>() { payload };

            var push = new PushNotification(true, "PushNotificationTest.p12", "pushchat");
            var result = push.SendToApple(notificationList);

            Console.WriteLine("Hello World");  
        }

Anyone has ideas?


Solution

  • Solved the problem by following the link:

    http://code.google.com/p/apns-sharp/wiki/HowToCreatePKCS12Certificate

    and then generating the .p12 file using the openssl approach.