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.
Never cache device tokens; 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. 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. 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.

你可能感兴趣的:(Registering to Receive Remote Notifications)