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.
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 by Matthijs Hollemans.
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.
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:
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:
The following screenshot shows the notification received on the iPhone device.
In this small article we learned how to setup the .NET application to send notification messages to APNS server's. Once, again it is highly recommended that you read the articles mentioned in the required reading to get detailed information about how APNS works.