Push notifications(APNs): Communicate with APNs using Authentication tokens

Aditi Agrawal
2 min readApr 12, 2020

What are Push Notifications?

Push notifications are ways to inform users for app developers to propagate information to iOS (and, indirectly, watchOS), tvOS, and macOS devices.

Push notifications use the Apple Push Notifications service (APNs) to deliver notifications to devices. Notifications can display a message, play a distinctive sound, or update a badge on an app’s icon.

For sending push notifications to iOS users, you can either communicate with APNs using the certificate or using an authentication token signing key.

It is always a great idea to create and upload the authentication key for a number of reasons.

The advantages of using APNs authentication token signing key:

  1. You can use the same APNs signing key for multiple apps.
  2. You can use one signing key to distribute notifications for all of your company’s apps.
  3. The signing key works for both the development and production environments.
  4. The signing key doesn’t expire. Alleviating the need to re-generate one every year like push certificates.
  5. Communications with APNs using authentication tokens offer a stateless way. Stateless communication is faster than certificate-based communication. Token-based authentication offers a stateless way to communicate with APNs.

Creating an authentication token signing key:

  1. Navigate to Apple Developer and log in.
  2. In Certificates, Identifiers & Profiles, select Keys from the sidebar, then click the Add button (+).
  3. Register a New key, with a unique key name.
  4. Under Key Services, select the Apple Push Notifications service (APNs) checkbox, and click Continue.

5. If you download the key, it is saved as a text file with a .p8 file extension in the Downloads folder.

Note: Save this file in a secure place because the key is not saved in your developer account and you can only download it once. If you lost the key file, you will need to revoke it and register a new one.

Let’s connect!

You can find me on GitHub.

--

--

Aditi Agrawal

I write about iOS, GitHub, Mobile development, Leadership and Life.