user1144596
user1144596

Reputation: 2098

App Deletion - APNS Response to Development Server on Push Notification Failure

I have an iOS app that receives notification from APNS. If my user deletes the app there is no way for the backend to know the app is not installed on a certain device(device token). In this case what error code will be generated when trying to push via APNS, so that i can remove the entry from the database?

Upvotes: 2

Views: 1165

Answers (1)

Pranav Jaiswal
Pranav Jaiswal

Reputation: 3752

There is a Provider (Your backend server) API introduced by Apple in WWDC-2015 & enhanced in 2016 to give more valuable feedback to the server about the push notification. Here is a transcript to that WWDC session.

From the transcript: "If a device token has been removed, you will get an HTTP/2 response with status 410, or "removed." It will have a time stamp in payload indicating when APNS last learned that the device token has been removed."

APNS Server Response Codes

  • 200 Success
  • 400 Bad request
  • 403 There was an error with the certificate or with the provider authentication token.
  • 405 The request used a bad :method value. Only POST requests are supported.
  • 410 The device token is no longer active for the topic.
  • 413 The notification payload was too large.
  • 429 The server received too many requests for the same device token.
  • 500 Internal server error
  • 503 The server is shutting down and unavailable.

Now what I cannot confirm to you is that if iOS removes the device token if app is removed or if notification setting is turned off from App settings without deleting app.
"410 does mean the app was uninstalled. The token will remain active if the user disables notification alerts in the app settings. The device will still receive the notification, even if no alert is shown to the user. The server will not know if the user has turned off notification alerts. Only the app knows this."
Thanks to Marcus Adams for clartfying this doubt.

Here goes the Apple Developer Guide!!!

If required, Here is a Paid SDK that can help you with uninstallation tracking.

Upvotes: 5

Related Questions