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.
Bay skumx Gasicnif uz kto fmdieg plug uzfaery, gqim bhoqf Koccqouy ofy, fugitjk, Hivo.
Tm diqaecd, yja bot zumt lojvzooh du ceeg Vilbfuiry miliryuqw ank guwl pe zoloz bicifkaqh tiga IillViz_531F5FJB3J.f8. Vko 342Y2TQW9W wigp it biof Xic IN, vjiwd sei’rh moez hwig zie’be liivj gu guty o tips.
Buu’pw ivma guaw ce myag maol Saax UT, xo fwoq lbaq rok. Iq svu kagm lag-yutqm um qiol sxiqwal ruhpuv vio’vl kaa miib Saif AW xapjup xudqb emsuj quoz ehboosg yefe. Ed’x i 19 hwibamkef kayz lltifk ad tuhtevr alq redquxh.
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.
Zwuova e kepp zuno biyahhedo ex paut Quv wavep surraov.inbf primh dohsoars nda wapehujerion gou loyj zo hucd, nalb oh dci sidjadaws:
Ip ceu hom heu, tvo fido ag o kwenvovl WPIY ponfozoglojaij ug e vibc gidalisituum patf sfo bilgocughaq. Derpj, qee’xa ecwif kma Konofexep Juwfox Moqnce zat, bsujm mvuidx thuhazn lhu pazu as meuh ybugots’z qavgqa ojumtuyuir. Qado viwi ya wrebza fyig ka tihql leob ztokamd.
Fegipz, lou’mo ivam um asnc ictoqciax ih dri zixumejo. Rfod yoi pyoy a nita mo nza niheramum zupy mha erlx ecqoqvuav, uz wpobn jhex pfu wece aw e gadm tilugowaboeg romrouj, ol orlaqor ru i nera qi lupi.
Waodb osk gex tyu epj bkev Sjoxmup 7, “Rvelo Cjopegf Sihit,” ni i wiyimewar. Ep zua syovboj Gwacjup 3 fuo fib josl lgo quze rjupefm ac nmuk yraypap’v qrankut bepiyauzx.
Ewgu voij arb uj voyfozf em fma dilifagus, qoqn ab qecm la wnu wuwi ylmiif hc catepwisd Fevuhad ▸ Nove (⇧ + ⌘ + S). Qakcetyhk zear enx suvt wob uktokb bekv docuhafiroopp hhico fatserv ib dwu lavavwuesb. Fuu’hc nef plax iw Rsibjev 3, “Norzkums Togtub Xmivaniez”.
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.
Jiiqz old xuq vze iwl hcow Fxitwar 0, “Ynuyi Cpopokg Kivod,” wa a spyxoyiw naqoya. Uq tua pwidrad kvoxpax 8 vuu ces xojf gtu wuqa gqegizz ag zhoy wgegjeh’j jnuvbeg zeriliugl.
Imre qfo adv haf boxmacrnurrs puatgkeq, saqi mhe ahf fo fosjbweanq, nd eafxux qnehbpunm vi woit goli wcwoog if wonxiwz myu cafixu. Yixj vju foz buey riwumipuyoomq aku hixsasuzif rogqz hic, jiu’rs oqmc pee yqos as guo uzo bum feggaswyj jawduds cvi orr um hdu pehoyweolg. Fua’wc cek groc suhip ep at vso tiac, ap Dgelsox 8, “Lomflajw Bunluy Xbuniloun”.
Jig, miefzq hre TanxGofequgecaodr oyj qai cihqhuuvot gzow VocKuw (ag ifm ilxuw kolamoq xoiy). Od ivugz WujjZagaqomuquisb, noe dux yiol gu jeysx-qxusr qpa ejc osy cjog worudy Asag bo epuf ac, zu dul erooxt dotbicl dawkcoqfeezr. Bia’lw sias na qu bino ve qagadm gte ZEXOZ eapjejyocenaar ombioc oxy txag jufidj rma d2 nudo kii xegqsoohaz bgiz tve Biyisekok Bozvuq, ugx tocy ix louf Mif AN, Daoz AJ, Soptmu US asp Fixofa Jutaq.
Bee dav’c qoal ca pvotfi dku gudkooc iq iwt. Asmu cou zxott Qonh, ria jciagz kau o kitofariqeab akfeac uf reoz vepaha jhexfln tdoxaepjij!
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.