Push notifications allows the iPhone users to get messages from Apple Push Notification Server which are sent by a user's server. Push notifications is the quickest way to remind a user about his upcoming appointment or alerts on his/her banking account. In this article we are going to send a push notification using Moon-APNS .NET Library.
Required Reading:
This article will NOT cover the certificate signing and creating the public/private keys for your iPhone app. We highly recommend that you check out the following two articles.
1) Apple Push Notification Service Tutorial Part 1/2
2) Apple Push Notification Service Tutorial Part 2/2
One thing we noted is that after following the above procedure we still had to create the PKCS12 format file for the notifications to work. We used the OpenSSL method of creating the PKCS12 file which worked out for us.
http://code.google.com/p/apns-sharp/wiki/HowToCreatePKCS12Certificate
Downloading and Using Moon-APNS:
Moon-APNS is the simplest .NET library for sending notifications. You can download Moon-APSN library using the following link:
https://github.com/arashnorouzi/Moon-APNS
After downloading simply add the references to the DLL's to your application. Also, make sure to place your .P12 file somewhere in the .NET application folder where it can be easily references. For this article we placed the .P12 file right into the Debug folder.
NOTE: .P12 file is the private key generated using the keyChain access application. Read this article to find out how to generate and use .P12 file.
The implementation of sending push notifications using Moon-APNS is shown below:
This article will NOT cover the certificate signing and creating the public/private keys for your iPhone app. We highly recommend that you check out the following two articles.
1) Apple Push Notification Service Tutorial Part 1/2
2) Apple Push Notification Service Tutorial Part 2/2
One thing we noted is that after following the above procedure we still had to create the PKCS12 format file for the notifications to work. We used the OpenSSL method of creating the PKCS12 file which worked out for us.
http://code.google.com/p/apns-sharp/wiki/HowToCreatePKCS12Certificate
Downloading and Using Moon-APNS:
Moon-APNS is the simplest .NET library for sending notifications. You can download Moon-APSN library using the following link:
https://github.com/arashnorouzi/Moon-APNS
After downloading simply add the references to the DLL's to your application. Also, make sure to place your .P12 file somewhere in the .NET application folder where it can be easily references. For this article we placed the .P12 file right into the Debug folder.
NOTE: .P12 file is the private key generated using the keyChain access application. Read this article to find out how to generate and use .P12 file.
The implementation of sending push notifications using Moon-APNS is shown below:
01 | static void Main( string [] args) |
02 | { |
03 | var deviceToken = "deviceToken" ; |
04 |
05 | var payload = new NotificationPayload(deviceToken, "your message" ,51); // 51 is the badge no |
06 | var notificationList = new List<NotificationPayload>() { payload }; |
07 |
08 | var push = new PushNotification( true , "aps_developer_identity.p12" , "password for the private key" ); |
09 | var result = push.SendToApple(notificationList); // You are done! |
10 |
11 | |
12 | } |
No comments:
Post a Comment