๐ APNs Certificates vs APNs Authentication KeyโโโWhich One Should You Choose?
Apple Push Notification service (APNs) enables iOS apps to receive remote notifications from backend servers. Whether youโre sendingโฆ

Apple Push Notifications
๐ APNs Certificates vs APNs Authentication Key โ Which One Should You Choose?
Apple Push Notification service (APNs) enables iOS apps to receive remote notifications from backend servers. Whether youโre sending alerts, messages, or silent updates, APNs is at the core of delivering that content to your app.
But when integrating with APNs, developers have two choices for server-side authentication:
- APNs Certificates (
.pem) - APNs Authentication Keys (
.p8)
Which should you choose โ and why? Letโs compare them, explore how the push flow works, and understand the pros and cons of each approach.
๐ฌ Apple Push Notification Flow โ How It Works
At a high level, the push notification flow looks like this:
- App registers for remote notifications iOS requests a device token from APNs and provides it to the app.
- App sends the device token to the backend Your server stores this token to send future notifications.
- Backend sends notification to APNs
This is where authentication happens โ either via
.pemor.p8. - APNs delivers the message to the device APNs validates the request, locates the target device, and pushes the notification.
โ Key Benefits of Using APNs Key
- Single Key for All Apps
A single
.p8key can be used across all apps in our Apple Developer account (both Dev and Prod), simplifying setup and eliminating the need to manage multiple certificates. - No Expiry or Renewals
Unlike
.pemcertificates that expire annually, APNs keys do not expire, reducing the risk of push failures due to expired credentials and avoiding manual renewal effort. - More Secure with JWT APNs keys use JWT-based authentication, which is more secure and better suited for modern cloud or serverless environments.
- Easier Backend Integration
The
.p8method involves generating and sending a signed JWT with each request, making backend integration cleaner and more flexible. - Lower Maintenance Overhead
No need to export, convert, or rotate
.pemfiles across environments. Maintenance is minimal with the.p8key approach.
๐ฒ How to Configure Push Notifications Using APNs Key and Certificate
Apple offers two authentication mechanisms for sending push notifications:
- APNs Certificate (
.pem) โ legacy method using TLS - APNs Key (
.p8) โ modern, JWT-based method
Letโs walk through both methods.
๐ Method 1: Using APNs Key (.p8) โ Recommended
โ Best for:
- New projects
- Server-less/cloud environments
- Teams managing multiple apps
๐ Step-by-Step Configuration
Step 1: Enable Push Capability in Xcode
- Open your Xcode project
- Go to
Signing & Capabilities - Add โPush Notificationsโ capability
Step 2: Register for Push in App
In your AppDelegate or SceneDelegate:
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { granted, error in
DispatchQueue.main.async {
UIApplication.shared.registerForRemoteNotifications()
}
}
Step 3: Create APNs Key in Apple Developer Portal
- Go to Apple Developer Account โ Certificates, IDs & Profiles โ Keys
- Click โ+โ to create a new key
- Check Apple Push Notifications service (APNs)
- Download the
.p8file (โ ๏ธ only once!) - Note the Key ID and your Team ID
Step 4: Backend Configuration
Use the .p8 key to sign a JWT for push authentication.
Sample JWT header:
{
"alg": "ES256",
"kid": "YOUR_KEY_ID"
}
Sample JWT payload:
{
"iss": "YOUR_TEAM_ID",
"iat": <UNIX_TIMESTAMP>
}
Generate this JWT using your .p8 key and attach it in the Authorization header.
Step 5: Send Push Notification
Make an HTTPS POST request to APNs:
POST https://api.push.apple.com/3/device/<device_token>
Headers:
- Authorization: Bearer <JWT>
- apns-topic: <your-app-bundle-id>
Body:
{
"aps": {
"alert": "Hello from .p8!",
"sound": "default"
}
}
๐ Method 2: Using APNs Certificate (.pem) โ Legacy
โ Best for:
- Legacy systems
- On-premise server setups
- Simple one-app environments
๐ Step-by-Step Configuration
Step 1: Enable Push Capability in Xcode
(Same as above)
Step 2: Register for Push in App
(Same as above)
Step 3: Create APNs Certificate
- Go to Apple Developer Portal โ Certificates
- Click โ+โ โ Apple Push Notification service SSL (Sandbox & Production)
- Select your App ID
- Upload CSR (from Keychain or OpenSSL)
- Download the
.cerfile
Step 4: Convert .cer to .pem
- Open Keychain Access โ Export
.p12from certificate - Use OpenSSL to convert to
.pem:
openssl pkcs12 -in pushcert.p12 -out pushcert.pem -nodes -clcerts
You now have a .pem file with both cert and private key.
Step 5: Send Push Notification
Use a library or curl:
curl -v \
--cert ./pushcert.pem \
--key ./privatekey.pem \
--header "apns-topic: com.example.myapp" \
--data '{"aps":{"alert":"Hello from .pem!"}}' \
https://api.push.apple.com/3/device/<device_token>
โ ๏ธ Notes:
- You need separate certificates for Dev and Prod
- Certificates expire yearly
- Must be updated manually on backend servers
โ Final Thoughts
If youโre starting a new project or migrating existing infrastructure, the APNs Authentication Key (.p8) is the clear winner โ it's easier to manage, more secure, and future-proof. While Apple still supports .pemcertificates, the .p8 method is clearly the path forward โ offering better scalability, maintainability, and security.
Still using .pem? Unless you have legacy constraints, Itโs time to plan a migration.
๋ฉํ๋ฐ์ดํฐ
- post_id
- 3bc065f97039
- slug
- apns-certificates-vs-apns-authentication-key-which-one-should-you-choose-3bc065f97039
- url
- https://medium.com/@sreejithbhatt/apns-certificates-vs-apns-authentication-key-which-one-should-you-choose-3bc065f97039
- canonical_url
- https://medium.com/@sreejithbhatt/apns-certificates-vs-apns-authentication-key-which-one-should-you-choose-3bc065f97039
- author_url
- https://medium.com/@sreejithbhatt
- status
- ok
- fetched_at
- 2026-07-22 10:05:19