Registering to Receive Remote Notifications

Each time your app launches, it must register with APNs. The methods you use for registering with APNs differ according to the platform, but the high-level process is as follows:
Obtain a device token from APNs using platform-specific APIs.

Send the device token to your server.

Device tokens are unique to a specific app and device. Upon receiving a device token, it is your responsibility to open a network connection to your server and forward the device token along with any other relevant data. On your server, use the device token and any other data to generate remote notifications for the specific device. When sending remote notifications to a device, you must always include the device token with the data you send to APNs.
<u><b>Never cache device tokens</b></u>; always get them from the system when you need them. Although device tokens are unique to an app and device, they can change over time.<u><b> The device token can change at any time but is guaranteed to be different when the user restores their device from a backup, when the user installs your app on a new device, and when the user reinstalls the operating system. </b></u>Fetching the token from the system ensures that you always have the current token needed to communicate with APNs. In addition, if the token has not changed, fetching it is fast and does not incur any significant overhead.
IMPORTANT
When the device token changes, the user must launch your app once before remote notifications can once again be delivered to that device.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容