Handling error responses from Apple Push Notification service
Respond to the status codes returned by APNs servers.
Overview
Apple Push Notification service (APNs) provides a response to each request your server transmits. Each response contains a header with fields indicating the status of the response. If the request succeeded, the body of the response is empty. If an error occurred, the body contains a JSON dictionary with additional information about the error.
Interpret header responses
The table below describes the meaning of the keys in the header response for a failed request.
Header name | Value |
|---|---|
| The HTTP status code. For a failed response the status code can be |
| The same value found in the |
The table below lists the possible values in the :status header of the error response.
Status code | Description |
|---|---|
400 | A bad request. |
403 | There was an error with the certificate or with the provider’s authentication token. |
404 | The request contained an invalid |
405 | The request used an invalid |
413 | The notification payload was too large. |
429 | The server received too many requests for the same device token. |
500 | An internal server error. |
503 | The server is shutting down and unavailable. |
Understand error codes
The key below is found in the JSON dictionary for unsuccessful requests. The JSON data might also be included in a GOAWAY frame when a connection terminates.
Key | Description |
|---|---|
| The error code (specified as a string) indicating the reason for the failure. The table below lists possible values. |
During testing, if you find that your test devices aren’t receiving push notifications sent by your provider server, refer to Troubleshooting push notifications to troubleshoot.
The table below lists the possible error codes included in the reason key of a response’s JSON payload.
Status code | Error string | Description |
|---|---|---|
|
| The feature isn’t enabled for this topic. Refer to Setting Up Broadcast Push Notifications to enable broadcast capabilities. |
|
| The |
|
| The |
|
| The |
|
| The JSON Request payload contained an unrecognizable attribute. |
|
| The JSON Request payload is unparseable. |
|
| The push notification request didn’t include a notification payload. |
|
| The |
|
| The |
|
| The |
|
| You have reached the maximum channel limit for your application. Delete channels that you no longer use. |
|
| The |
|
| The topic is not allowed. Ensure that no push type suffix is added to the bundle ID. |
|
| The |
|
| The certificate is invalid. |
|
| The client certificate is for the wrong environment. |
|
| The bundle IDs parsed from your token or certificate don’t include the topic present in the path. |
|
| No certificate or JWT token provided. |
|
| The JWT Token is expired. |
|
| The JWT Token is invalid. |
|
| The URL is invalid. Either the |
|
| The specified |
|
| The message payload is too large. For information about the allowed payload size, refer to Sending Broadcast Push Notification Requests To Apns. |
|
| The request was throttled because too many requests were received. |
|
| The provider’s authentication token is being updated too often. Update the authentication token no more than once every 20 minutes. |
|
| An unexpected error occurred. |
|
| The service is unavailable |
|
| The server is shutting down and unavailable. |
The following code snippet shows a sample response when an error occurs.
HEADERS
- END_STREAM
+ END_HEADERS
:status = 400
content-type = application/json
apns-request-id: <a_UUID>
DATA
+ END_STREAM
{ "reason" : "MissingChannelId" }