Back to Glossary
Mobile & Push

APNs(Apple Push Notification service)

Apple's cloud service that delivers push notifications from your server to apps on iPhone, iPad, Mac, Apple Watch and Safari.

Definition

APNs (Apple Push Notification service) is the delivery network Apple runs for every remote notification on its platforms. Your server never talks to an iPhone directly. It sends a request to APNs over HTTP/2 with the device token, your app's bundle ID as the topic and a JSON payload, and APNs forwards the message to the device when it is online. APNs is also how Live Activity updates, background pushes and Safari web push reach Apple devices.

Why It Matters

If you want to reach iOS users with push, APNs is not optional: every iOS notification, whether you send it yourself or through a vendor such as Firebase, OneSignal, Braze or Sequenzy, ends up as an APNs request. Knowing how APNs authenticates and reports errors explains most iOS push problems, from silent failures in production builds to tokens that stop working after a reinstall.

How It Works

You authenticate with either a token-based .p8 auth key (keys do not expire, but their topic and environment scope can vary) or a certificate-based .p12 file (one per app, renewed every year). Each request carries headers such as apns-topic (your bundle ID), apns-push-type (alert, background, liveactivity and others) and apns-priority, plus a JSON body whose aps dictionary holds the alert, sound and badge. Apple runs two environments: sandbox for development builds and production for TestFlight and App Store builds, and a token from one does not work in the other. Payloads are limited to 4 KB for regular notifications. When a token is no longer valid, APNs answers with status 410 so you can stop sending to it.

Example

A minimal APNs alert payload:

{
  "aps": {
    "alert": {
      "title": "Your trial ends tomorrow",
      "body": "Keep your playlists with Premium."
    },
    "sound": "default",
    "mutable-content": 1
  },
  "deep_link": "myapp://paywall"
}

The mutable-content flag lets a Notification Service Extension download an image before the notification is shown.

Best Practices

  • 1Use a .p8 auth key instead of yearly .p12 certificates so pushes do not stop when a certificate expires
  • 2Match the environment to the build, sandbox for Xcode debug builds and production for TestFlight and App Store
  • 3Set apns-push-type correctly, since background and Live Activity pushes are rejected or throttled without it
  • 4Keep payloads well under 4 KB, especially when merging personalized text
  • 5Stop sending to tokens that return 410 Unregistered until the app registers them again; investigate environment or formatting for BadDeviceToken
  • 6Store your key ID and team ID with the key, since you need all three to sign requests

Connect APNs with one .p8 key

Upload your APNs auth key, key ID, team ID and bundle ID in Sequenzy, and the same key powers alerts, rich push with images and iOS Live Activities.

Learn More

APNs Authentication Options

Method File Expires Scope
Token-based .p8 auth key Never (revocable) Team-scoped or topic-specific; check the key's environment
Certificate-based .p12 certificate Every 12 months One app; a Sandbox & Production certificate can cover both environments

Common APNs Errors

Status Reason Fix
400 BadDeviceToken Token is from the other environment or malformed
403 InvalidProviderToken Check key ID, team ID and signing
410 Unregistered Token is inactive for this topic; stop sending unless the app registers it again
413 PayloadTooLarge Keep ordinary payloads at or below 4,096 bytes; VoIP allows 5,120 bytes

Frequently Asked Questions