One of the greatest strengths of the ecosystem of iOS is the vibrant community of developers and a wide range of open source libraries and tools. There's a ton of goodness for both Objective-C and Swift (already).
One the other hand, one of the most dreaded things is code signing and certificates. One thing that requires a certificate is enabling an app for Push Notifications. To actually push notifications to devices, you need a certificate on your server/machine when sending and this certificate needs to be bundled into the provisioning profile the app was built with.
You can easily spent a fair amount of time managing certificates and provisioning profiles in the developer portal.
It is easily installed as a Ruby gem and all you need in order to acquire a push certificate is run
pem in the command line and type in the bundle identifier of your app.
Just look at this:
Quite amazing indeed!
What's even more awesome is that now you'd normally have to go to the developer portal and update the provisioning profile to include the push notification entitlement and certificate, so that you can refresh the profiles from Xcode to bundle into your app.
All you need to do now is go to Xcode and refresh provisioning profiles and you're good to go.
Sending push notifications from the command line
Installation is simple and to sent push notifications you need the certificate you got earlier.
$ apn push "<token>" -c /path/to/apn-dev-cert.pem -m "Hello from the command line!" ``` Note that this will by default use the development (sandbox) environment. To use the production environment you need to set the `-e` flag to `production` when running the command.
$ apn push "
A quick and dirty way to query the [feedback service](https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/CommunicatingWIthAPS.html#//apple_ref/doc/uid/TP40008194-CH101-SW3) using Houston is using the script below: <script src="https://gist.github.com/martinnormark/f2ccbd85db1b633c8526.js"></script> This will return a list of device tokens with their timestamp of failed delivery from the feedback service. A failed delivery occurs when the device uninstalled the app - not when the user disabled push notifications. Apple doesn't expose the user's choice to app developers so that they can keep asking to change settings. According to the docs, you should query the feedback service daily: >Query the feedback service daily to get the list of device tokens. Use the timestamp to verify that the device tokens haven’t been reregistered since the feedback entry was generated. For each device that has not been reregistered, stop sending notifications. APNs monitors providers for their diligence in checking the feedback service and refraining from sending remote notifications to nonexistent apps on devices.
Subscribe to Martin Normark's Blog
Get the latest posts delivered right to your inbox