Push notifications(APNs): Communicate with APNs using Authentication tokens
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:
- You can use the same APNs signing key for multiple apps.
- You can use one signing key to distribute notifications for all of your company’s apps.
- The signing key works for both the development and production environments.
- The signing key doesn’t expire. Alleviating the need to re-generate one every year like push certificates.
- 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:
- Navigate to Apple Developer and log in.
- In Certificates, Identifiers & Profiles, select Keys from the sidebar, then click the Add button (+).
- Register a New key, with a unique key name.
- 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.