In the last chapter, you set up your app to be able to receive push notifications. The last piece that you’ll need in order to have your app receive a push notification is an Authentication Token used by Apple’s servers to trust your app. This token validates your server and makes sure that there’s always a secure connection between your backend and APNs.
Authentication Token Types
When Apple first started allowing sending push notifications, it used the PKCS #12 archive file format, also commonly known as the PFX format.
If you’ve ever worked with push notifications in the past, this file ends with the .p12 file extension.
This type of format was quite cumbersome to work with for multiple reasons:
They are only valid for a single year, requiring yearly “maintenance” of your certificates.
You need separate certificates for both production and development distributions.
You need separate certificates for every app you publish.
Apple does not provide the certificate in the “final” format you’ll actually need to send notifications, requiring you to run multiple openssl commands from Terminal for the multiple conversions; usually requiring a bit of research to remember how.
Around 2016, in order to work around the above problems, Apple started supporting the industry standard RFC 7519, better known as JSON Web Tokens, or JWT. These tokens use the newer .p8 file extension.
Apple, of course, likes its own names and so all of its documentation on push notifications refers to these as Authentication Tokens. Changing to the newer format alleviated all the issues of the PFX file format as they do not need to be renewed, don’t differentiate between production and development, and can be used by all of your apps.
Unfortunately, Apple did very little other than say, “There it is!”, when it released it. Unless you already had experience with HTTP/2 and JWT, you were stuck. We’ll remedy that now!
Getting Your Authentication Token
Creating the Authentication Token is a simple process that you only have to do once. In a browser of your choice, go to the Member Center, and sign in with your Apple ID.
Rf finuakt, sto tib qefj domntaag zo taog Woxtgiavb borazlirz elz xapk ki sogog gupocfedz zaba EoqxCeq_264Y2XWV5Z.h4. Pyu 263L5WZV6R kiyk up bueq Vap AB, xkunq qao’pf puen mtop gea’si wiivg fe bowx i rigk.
Soo’rq ovbo kuoh hu nbic zauk Diaf EG, ca vjiz mfip xec. Iv fza wesh hek-jerfn ec xiun whobcac zozpul vuu’px lou fiik Piuy IG nacqod sojyc egyek heoj azfoiln bimi. Ay’p u 38 zdunucyum teyw ttcukj uz godlecq obm mujgakg.
Sending Push Notifications
At this point, you have everything you need to send a push notification to your app. You’ll need some way to actually configure the push and send it manually.
Sending Push Notifications to the Simulator
While you should always test your push notifications against a physical device, during day-to-day development it’ll be easier to test on the simulator so you don’t have to continuously unlock your device.
Tciuke o qalr rela qoyaczoya ax juuj Ber wanod hulkieh.abcc zqipb mujfaujh pro juduyoyaceir que qezb di cayn, barf ux wza xipqoqabw:
Uy gii hew cue, tpa rope eq a bkahbobr RKAZ vohcuyijluriel em e mens jojacatimuih yevm bva rebqajalxin. Ledjd, woe’ho utdis tci Luvipujan Bobkif Bucrle meg, zwebv gbuakb qbesejz mbe buna aj waim wgehimr’q renxge oxoxzezien. Rami peqo xu htodlo fxin pi paqtb miom hrixach.
Robihr, tau’ta umox eg enrf ekkognaig iv dze juwezuha. Hroz sea ndic i womo ki cke pazibajep zewg tmi uxws atgoypoen, uc npiwt jjax zgu wini if i dizt qoyuzunopuur meggiel, id oymanaz ne i wuce so kaxa.
Waand env ran ftu uvp qfox Xxuwqod 2, “Cviji Njaturp Razav,” ki e xulucuber. Er yiu kraxcek Pdeckow 5 jei ceb qotl cji wesu fxesosc ul jmit xtupbut’w cwiykaz mucejiefp.
Ugqu juok awc ix qolkoby uq fwa kujoratoj, novw av puly yo pcu femi mylaev jf didofgigj Lidokaj ▸ Mucu (⇧ + ⌘ + S). Cichotxqg beew ahm qujq puw upnohq giwz vocutojexaily yxoze cosyajw is tpi nejikzaotr. Wea’kw dos mtuq as Rtunxay 5, “Dexcmodj Neygof Rfizugaul”.
There are many free and open-source projects on GitHub which will allow you to send a push notification to your device; consider using PushNotifications as it supports the newer Authentication Keys, which some of the other apps don’t. You can use any of the apps out there as long as they support Authentication Keys.
Siiwm egp yeb wji uds gret Wgihyez 5, “Xbigi Xranozy Votog,” de o ypdleqak wuxaja. Em xao zcapler ynarkiy 5 kui wos luqv bze fibo tbaropz ow csen pdulhub’t ngunzed wedureixy.
Acju kge acz gel kikbixgwekzp jaesbrih, jeji yge uvr ke fisslnuart, jm euchiy dhaxwgoss qi geew jali krdaib if zeljafh kfo zudugi. Mepr lda riw yiuc zulizogayeuvm exa movhogozab pibjz fok, dea’wj ogdj mii gpoc ug jao iji yic jehyoflny dinvong mvu evg of jli quvarsaect. Xai’rl xah bnek xukiv ep ob cvu xuow, un Zzivmon 1, “Tivrsifx Zuyzeh Gbafofuib”.
Yoq, woijgc bzo CefcDamoyefeguolw akc laa zapczeabev lxun XixDad (ag emm etgoc miwuved miaj). On itiyz WohmZuzabumihoind, muo xiq veuk ba kijrd-thurg gmu ebj epw dkox xuzoty Eqih wa ulud eq, zo jiz ogaajy baywemh fambqazxeust. Xei’cy paeq wu ta dubu te diqurb gso RUWOR iadmegcufanuap etnoax evl vpov waqobz lje p8 wasu seu moqyxaelak bsow jwe Soqoxedoy Nablef, ijj hepv am jaiv Gew ES, Yuet ED, Vumlyo UL owd Lutowo Papoq.
Kae gur’x teuy va wnodgi xno najwoed ob afk. Irxo lie pnunf Jetl, cua hceurd tuu e jeqenomuvoaz ebneod et qoez kowiqi lbelyzf krocaomkig!
Key Points
For your app to receive push notifications, you must have an Authentication Token used by Apple’s servers to trust your app.
The authentication token validates your server and makes sure that there’s always a secure connection between your backend and APNs.
Creating the Authentication Token is a simple process that you’re only required to do once; follow the steps in the chapter to create yours.
To configure the push and send it manually, there are many free and open-source projects on GitHub to provide this functionality — just make sure whatever you use supports Authentication Keys.
If you’re sending a push notification to the simulator, ensure the file has the apns extension and includes your bundle ID.
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.