device tokens for Apple Push Notifications provider

五迷三道 提交于 2019-12-07 08:26:48

问题


If I'm an Apple Push Notification "provider" for multiple iOS apps can I use the same device token for multiple apps? I'm aware that I need unique SSL certificates for each app. However I'm confused about the device tokens.

Example: I have two apps A and B. I want to provide push notifications for both apps. Say I collect a device token T from a user who installs app A. Assume I have unique SSL certificates for both apps. When the same user installs app B can I re-use token T when providing push notifications for app B?

More info: After re-reading Apple's docs it's still not clear. This paragraph in particular seems to imply the device token can be re-used:

Every notification that a provider sends to APNs for delivery to a device must be accompanied by the device token it obtained from an application on that device. APNs decrypts the token using the token key, thereby ensuring that the notification is valid. It then uses the device ID contained in the device token to determine the destination device for the notification.

Note: Sounds like the "topic"/bundleID contained in the provider's SSL certificate for each app directs the notifications to a particular app on a device. So it seems plausible that device tokens are unique for a device (and not for apps on the device).


回答1:


For the two apps A and B the device token will be the same for sandbox ssl certificate, but it will change for distribution profile (i.e when using production ssl certificate)

Also, the device tokens might change when you upgrade the OS

I too have developed a "provider" and I prefer to store device tokens per app. i.e (APP_A => Token1; APP_B => Token1) Everytime a device sends a registration request to the provider, check if the combination of the APP and device token exists in the table, if not do a new insert.

This way you don't have to worry even if the device token changes for some reason.



来源:https://stackoverflow.com/questions/8188274/device-tokens-for-apple-push-notifications-provider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!