This is quite the experience learning Objective-C and all the quirks to get an application running on an iPad. I'll say that I really like the experience, and thin that Objective-C is a very interesting language, simultaneously being both archaic and powerful in the way it handles objects and messaging.
But this post is not about Objective-C. It is about how to write a C# application that can send messages to a iOS device using Apple Push Notifications (APN's). The need for having this done in C# is a requirement of the system I have been developing, as all the internal systems are written in .NET and therefore the easiest and most maintainable code for sending messages would be in C#.
This entire process is quite a bit different from .Net development and deployment. These steps are required by Apple for various reasons, primarily of which is security and quality of experience. You need to prove to Apple that you are a registered developer (step 1), let them know all the devices you will deploy your applicaiton to (step 2), let Apple know your application by name and code signature (steps 3 and 5), which devices are allowed to run your application (step 5), and that you want to them to build channels between your application and APN servers for you to deliver message to your users.
It's worth noting briefly that these steps are required for an enterprise deployment of the application. Device registration and application provisioning is not strictly needed when deploying your application to the App Store.
Click the 'Continue' button and go to next step.
Click the “Download” and double click to install.
Open the Utilities folder and launch Keychain Access. Select your bundle name appear on screen.
Note that I have expanded the top level item to show the private key that is part of the certificate. You will need that private key to generate a certificate file for the C# application to use. Right click on the private key and select export and save the file as a .p12 file, and I'm going to use developer_private_key.p12 as its name. You will be asked to prive a password for the file which will be used to encrypt the data in the file. Create a password and save it as it will be needed later.
Note: Make sure to edit and install your Provisioning Profile or create new one.
Please add the following External references. Then add to the reference from External reference folder.
Calling procedure. Please verify the below sample code.
Add PushBrokerHandler calss to your project. Refer the below PusBrokerHandler class.
//assemblies, and having the correct 'using PushSharp;' in your file since they are extension methods!!!
//you want it to handle. In the case of WindowsPhone, there are several notification types!
////IMPORTANT: For Windows Phone you MUST use your own Endpoint Uri here that gets generated within your Windows Phone app itself!
In Android send the multiple push notification using the below code.
//Error "The remote server returned an error: (400) Bad Request"
In Ios send the multiple push notification using the below code.
Using PushBrokerHandler class method to send the notification.