• info@happli.be

Tag Archive Azure

Phonegap – APNS push notifications with PushPlugin, Azure Notification Hub

There are a many plug-ins out there to help you with push notifications. I’ve used PushPlugin:  https://github.com/phonegap/phonegap-plugin-push

I’ve spent quite a lot of time getting the whole APNS-Azure Notification Hub-iPhone flow working. Just getting started requires quite a lot of prerequisites:

  • An Apple Developper Account (99$/year)
  • A Mac, so that you can generate certificates using KeyChain
  • A Windows Azure subscription (free trials exist), with a Notification Hub
  • An iPhone (I didn’t try, but it looks like you won’t get it working on iOS Simulator)
  • A phonegap project.

Here are a few things that have been time-consuming:

Not having a Mac

Working on the sources on a PC, Uploading the sources to phone gap build, waiting for the build to finish, downloading the IPA package, importing it to iTunes then synchronising it with the iPhone is… as you guess very time consuming. Yes, I’ve tried to work with Phone Gap’s hydration. Still it remains a lot to package everything in a zip, then upload it to PhoneGap Build. Yes, there exists a Phone Gap Build REST API that one could use to automate an upload-then-build process (and maybe such tools already exist, I haven’t searched for them). Even though you automate that step, it’s still slower than compiling locally from a Mac. Moreover, not having a Mac prevents you from having a decent debugging experience (see that post to find out how to debug your phone gap App using Safari).

All-in-all I’ve lost a lot of time trying to do without one, but I finally resorted to getting a Mac.

Get a Mac.

Getting the token

Getting the token from APNS isn’t hard if you get the correct certificates. Pay attention to your phone gap projet name. It must match the Application Identifier you create in the Apple Developer portal. Can cost a lot of time

Registering the token

Passing the token to the intermediate push server (the notification hub in our case) hasn’t been easy. I couldn’t find an easy-to-use javascript client for their API. I’ve used the Azure Mobile Service phone gap plugin. Indeed, with every Azure Mobile Services you get a Notification Hub associated. The phone gap plugin lets you access that Notification Hub, as shown below.

Azure notification hub apns token registration


  1. I used to call registerTemplate for APNS. It never worked. I had to call registerNative. It took me quite long before I tried that.
  2. There might be a better way to register the token with Notification Hub. Leave a comment in case you know of one.