Notification Tokenism in iOS
Apple has redesigned push notification authentication. Take a look at what they've changed.
Join the DZone community and get the full member experience.Join For Free
starting with a review of the http/2 based provider api, you will learn about an important new feature: token based authentication. learn to connect to apns using authentication tokens for sending pushes via the http/2 api, relieving you of the overhead associated with maintaining valid certificates.
ah, yes. longtime readers will remember various instances of untrammelled joy (where by “joy” we mean “near-homicidal frenzy”) apns has provided over the years, so this is a very interesting indeed development. full details were published september 20 at local and remote notification programming guide / apple push notification service and announced september 22 . so let’s check this out, shall we? especially as we got the annually dreaded “this certificate will no longer be valid in 30 days.” email day before yesterday, which makes the timing entirely apropos!
step 1: oh look, now under certs in the dev portal we have this new “apns auth key” option! so add one, and…
step 2: read the instructions:
download, install and backup
download your authentication key to your mac, then double click the .key file to install in keychain access. make sure to save a back up of your key in a secure place. it will not be presented again and cannot be retrieved at a later time.
step 3: be confused as the download gives you a .p8 file, not a .key file, and it’s not evident how you get that into the keychain.
step 4: check out the discussion on the dev boards :
it’s a pem-encoded, unencrypted pkcs#8 file. you can inspect it with `openssl pkcs8 -nocrypt -in <your_file.p8>`, but you’ll need a newer version of openssl than the one that ships with el capitan (i’m not sure which version comes with sierra). i’m not sure how to import it into the keychain, but i also haven’t run into a situation where having it in the keychain would be helpful (other than just for storage).
step 5: ok then, let’s find some service that can use this shiny new .p8 file then…
step 6: ¯\_(ツ)_/¯ not much out there yet!
alright, so we’ll keep working with a cert-based process for the moment then, check for updates! below once we find some. in the meantime, development tools that can work with the shiny newness? hmmmm … looks like you’re pretty much on your own there too as we write this. right then, if you know of any token-supporting services or tools, hit the comments section!
if you’re proactive enough to want to help move the development tools scene along, our goto for apns tinkering for a while now has been knuff : “the debug application for apple push notification service (apns).” along with knuff-framework “just add it to your application and the phone will be visible under “devices”” and knuff – the apns debug tool on the app store ! pretty complete ecosystem there and we strongly encourage helping out with it if you’re interested in this space.
if you’re new to this apns thing, or if you’d simply like a straightforward http page to use for testing, check out this new site pushtry.com to, eponymously enough, try pushing:
nicely done tutorials for both ios and android, clean and functional; definitely recommend you give that a pushtry. and they’re working on token support too!
should you be looking to get this on your server side asap, a quick look around for projects at least using http/2 apns, that being kinda the floor for ‘actively maintained’ currently, in a variety of environments turns up these:
vaporapns “is a simple, yet elegant, swift library that allows you to send apple push notifications using http/2 protocol in linux & macos. it has support for the brand-new token based authentication but if you need it, the traditional certificate authentication method is ready for you to use as well. choose whatever you like!”
swift-apns : “swift framework for sending apple push notification over http/2 api”
node-apn : “a node.js module for interfacing with the apple push notification service.”
apnsphp : “apple push notification & feedback provider”
apns/2 “is a go package designed for simple, flexible and fast apple push notifications on ios, osx and safari using the new http/2 push provider api.”
and again, if you have good … or bad … experiences with any particular piece of apns server kit, let us know!
Published at DZone with permission of Alex Curylo, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.