iOS Push Notifications, Amazon SNS

Today, I set out to find answers for following 2 questions

  1. Can APNS device token change?
  2. Does Amazon SNS handle token changes?

For 1st, I figured that device tokens can change. Apple developer docs mention following
Note: A device token is not a unique ID that you can use to identify a device. Device tokens can change after updating the operating system on a device. As a result, apps should send their device token

Looking at other sources, it seems OS update is not the only event that can change the device token. This includes Device Reset, Wrong Backup Restore (of a different device) and 2 years lifetime elapsed. Refer http://stackoverflow.com/a/7999690

Now, I wanted to know if this can be handled by Amazon SNS, instead of me creating a device token change notification from my app. 
Turns out, Amazon SNS does handle it by disabling the end point, for which GCM / APNS has notified of expiry or replacement. SNS also notifies this through an event.
GCM does a better job in its notification, and also reports the new token along with old / expired one. SNS then, instead of disabling the current end point, replaces the old token with new one. This reduces the overhead of new endpoint creation, and removal of disabled one.

Finally it means, for my iOS app, I will need a notification service from app to notify me of device token change. I will have to create a new endpoint to ensure notifications get delivered. I can (optionally) choose to remove the old endpoint.

Comments

Popular posts from this blog

504 Gateway Timeout on Amazon AWS ELB (Elastic Load Balancer)

AWS RDS incompatible-parameters solved

Push Notifications to iOS not received from Amazon SNS