Apple Push Notification Service Gem
Woo hoo I’ve written my first gem! Over the last couple of months I’ve been playing around with Apple’s new Apple Push Notification Service (APNS). I’ve written up a little gem to incapsulate the main functionality of APNS. I named it APNS for obvious reasons and put up the code on github. It’s easy to install using github’s gem server:
gem sources -a http://gems.github.com
sudo gem install jpoz-apns
All the basic setup is done on the class. APNS has 4 configuration variables: host, pem, pass and port. For development you probably only have to set 1, maybe 2 of these variables to get going. APNS.host’s default is Apple’s development server and the port is the same across development and production. Here’s an example to setup for a production environment. For development you don’t need to set host.
Notifications can be set two ways: just text, or as a hash of attributes.
Send other info along with aps
You can send other application specific information as well.
This will add the other hash to the same level as the aps hash:
Getting your iPhone’s device token
After you setup push notification for your application with Apple. You need to ask Apple for you application specific device token.