Clicky

iOS Dev Nugget 177 Push Notifications Testing During Development

.

Need to run a code review on your codebase? Hire me

Apple announced a new APNS Provider API a few months ago in 2015 based on HTTP/2. The older API had a binary interface and you had to connect to 2 Apple endpoints — one to send push payloads, the other a feedback endpoint where you listen for no-longer valid device tokens. The newer API is much cleaner, you connect to a single endpoint, POST your payload and gets a response, which may inform you that the device token is no longer valid.

I worked on adding push notifications support to a new app recently and wanted to look for 2 things (1) a tool on the desktop that I can initiate test pushes from (2) a RubyGem that supports the new APNS provider API that can be used from server side code.

Testing from Desktop

Pusher is a great (and simple) OS X app that you can use for sending pushes. You can install it via Homebrew cask. If you haven't installed or used Homebrew, check out Nugget #170 for an explanation of what it does. Homebrew-cask is now included with Homebrew, so if you previously had brew-cask installed, you will need to:

  1. remove it by running: brew uninstall --force brew-cask
  2. then update Homebrew by: brew update.

You can then install Pusher by running brew cask install pusher. The app is pretty explanatory. There's a bonus in the README which even goes into detail of how to generate the push certificate as well as boilerplate code to handle push in your iOS app!

RubyGem for Server

There aren't many RubyGem that support the newer APNS Provider API yet. In fact, I only found one — lowdown by @alloy. It can be installed with gem install lowdown. While it's meant to be used on the server-side, it includes a command line that you can use to initiate pushes for testing purposes, much like Pusher:

lowdown -m "test message" -e development -c <path to PEM file> --debug --verbose <device token>


Your feedback is valuable: Do you want more nuggets like this?   Yes   or   No

.

.

Like this and want such iOS dev nuggets to be emailed to you, weekly?

Sign Me Up! or follow @iosdevnuggets on Twitter

.

View archives of past issues