Prompt

How do I diagnose APNs errors from my notification backend?

Technology / API Platforms1 observationLast seen Oct 14, 2026

Latest observation

Oct 14, 2026OpenAI APIWeb search: off

To diagnose APNs errors from your notification backend, focus on both the HTTP response from APNs and the behavior of your token/device lifecycle. APNs errors usually fall into a few categories: authentication, payload, token validity, topic/environment mismatch, and delivery throttling/expiration.

1) Log the full APNs response

When you send a notification, capture:

  • HTTP status code
  • APNs error reason from the JSON body
  • apns-id response header
  • Request metadata:
    • device token
    • topic/bundle ID
    • push type
    • environment (api.push.apple.com vs api.development.push.apple.com)
    • expiration
    • priority
    • collapse ID
    • timestamp

APNs commonly returns JSON like:

{
  "reason": "BadDeviceToken"
}

or

{
  "reason": "Unregistered"
}

The reason is the key diagnostic signal.

2) Interpret common APNs errors

Here are the most common ones and what they usually mean:

  • BadDeviceToken

    • Token is malformed, expired, from the wrong environment, or tied to a different app/team.
    • Check that you’re sending to the correct APNs environment and using the latest token from the device.
  • Unregistered

    • The app was uninstalled or APNs no longer considers the token valid.
    • Stop sending to this token. Remove it from your database.
  • DeviceTokenNotForTopic

    • The device token doesn’t match the apns-topic you used.
    • Verify bundle ID / topic, especially with app extensions or multiple targets.
  • TopicDisallowed

    • Your certificate/auth key isn’t allowed for that topic.
    • Check Apple Developer settings and entitlements.
  • BadTopic

    • Missing or incorrect apns-topic.
    • Ensure it exactly matches the app’s bundle identifier unless using a special topic.
  • PayloadTooLarge

    • Payload exceeds APNs size limits.
    • Reduce payload size; keep custom data minimal.
  • BadPriority

    • Invalid apns-priority for the given push type.
    • Common values are 5 and 10; background pushes typically use 5.
  • BadPushType

    • Missing or incorrect apns-push-type.
    • Must match the notification type (alert, background, voip, etc.).
  • ExpiredProviderToken

    • If using JWT auth, your provider token is too old.
    • Refresh your signing token regularly.
  • InvalidProviderToken

    • JWT is malformed, signed with wrong key, or claims are incorrect.
    • Check team ID, key ID, and signature generation.
  • TooManyRequests

    • You’re being rate limited.
    • Back off and retry with exponential delay.
  • Shutdown

    • APNs is temporarily unavailable.
    • Retry later.

3) Verify environment and token source

A very common issue is mixing sandbox and production.

  • Tokens from development builds generally go to api.development.push.apple.com
  • Tokens from App Store/TestFlight/production builds go to api.push.apple.com

If you send a sandbox token to production APNs or vice versa, you’ll often see BadDeviceToken.

Also confirm:

  • the token was generated for the same app bundle ID/topic
  • you’re not sending stale cached tokens
  • the user has not restored to a different device/account state

4) Check headers and push type

APNs is strict about headers.

Typical required headers:

  • apns-topic
  • apns-push-type
  • authentication header (authorization: bearer <jwt>) or certificate-based auth

For example:

  • visible notification:
    • apns-push-type: alert
  • silent/background notification:
    • apns-push-type: background
    • usually apns-priority: 5
    • payload must include content-available: 1

If headers don’t match the payload, APNs may reject the request.

5) Validate payload format

Make sure the payload is valid JSON and conforms to APNs rules:

  • top-level aps dictionary exists
  • alert fields are structured correctly
  • badge is numeric
  • sound is valid
  • background pushes contain content-available: 1

Example alert payload:

{
  "aps": {
    "alert": {
      "title": "Hello",
      "body": "Message text"
    },
    "badge": 1,
    "sound": "default"
  }
}

Example background payload:

{
  "aps": {
    "content-available": 1
  }
}

6) Handle token lifecycle correctly

On the backend, maintain a token registry:

  • store tokens by user/device
  • update tokens whenever the app reports a new one
  • delete tokens on Unregistered
  • mark suspect tokens after repeated BadDeviceToken

Also note:

  • tokens can change after reinstall, restore, or sometimes OS/device changes
  • don’t assume a token is permanent

7) Use apns-id for tracing

APNs returns an apns-id header on successful requests and often on failures. Log it and correlate it with:

  • your request logs
  • device-side logs
  • Apple system logs if available

This helps you track a single push through your system.

8) Reproduce with curl or a minimal client

If your backend is complex, test the same request manually.

This helps isolate whether the problem is:

  • your backend code
  • token/topic/header formation
  • APNs credentials
  • payload content

9) Check for certificate/JWT auth issues

If using certificates:

  • verify the certificate is valid and not expired
  • ensure it matches the app’s APNs environment

If using JWT:

  • confirm:
    • iss = Apple Team ID
    • kid = Key ID
    • ES256 signing
    • token is refreshed within Apple’s allowed window
  • ensure your server clock is correct

10) Use APNs status codes as a guide

Common HTTP statuses:

  • 200: accepted by APNs
  • 400: bad request (payload/header/token issue)
  • 403: authentication/authorization issue
  • 405: wrong HTTP method
  • 410: token no longer valid (Unregistered)
  • 413: payload too large
  • 429: too many requests
  • 500/503: APNs temporary server issue

Practical debugging checklist

  1. Log APNs status, reason, and apns-id
  2. Verify production vs sandbox environment
  3. Verify apns-topic matches your bundle ID
  4. Verify apns-push-type matches payload
  5. Check JWT/certificate validity
  6. Test token freshness and user uninstall/reinstall cases
  7. Retry only on transient errors like 500/503/429
  8. Remove tokens on Unregistered

If you want, I can also give you:

  • a table of APNs error reasons and fixes
  • a Node/Python sample for logging APNs failures
  • a backend troubleshooting flowchart

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.