[iOS]Push Notification on iOS(1)
Push Notification on iOS
Brief Flow
- Send Notification request to APNs
- APNs delivers the notification to target Devices(APPs)
- APNs will retry later if device power off.
Pushing remote notifications from multiple providers to multiple devices
Establishing certificate-based provider connection trust
Establishing and using token-based provider connection trust
Establishing connection trust between a device and APNs
Managing the device token
Remote notification path from provider to device
Provider Server
-
Device tokens from APNs
-
Build and sent notification request to APNs
-
Schedule Task
-
Certificate
For security, APNs requires you to refresh your token regularly. Refresh your token no more than once every 20 minutes and no less than once every 60 minutes. APNs rejects any request whose token contains a timestamp that is more than one hour old. Similarly, APNs reports an error if you recreate your tokens more than once every 20 minutes.
On your provider server, set up a recurring task to recreate your token with a current timestamp. Encrypt the token again and attach it to subsequent notification requests.Provider certificates are valid for a year and must be updated to continue communicating with APNs.
-
Implementation
APNs (Apple Push Notification service)
- JSON Web Token (JWT) & Certificate
- Encrypt/Decrypt Device Token
- Deliver Push Notification
Client App (Remote Notification)
- Enable Push Notification (Xcode & Apple Account)
- Register with Apple Push Notification service (APNs) and receive an app-specific device token.
- Send the device token to your notification provider server.
- Device Token
APNs can issue a new device token for a variety of reasons:
User installs your app on a new device
User restores device from a backup
User reinstalls the operating system
Other system-defined events
As a result, apps must request the device token at launch time
To protect user privacy, do not use device tokens to identify user devices.
-
Implement support for handling incoming remote notifications
NOTE
The ability of APNs to deliver remote notifications to a nonrunning app requires the app to have been launched at least once.
On an iOS device, if a user force-quits your app using the app multitasking UI, the app does not receive remote notifications until the user relaunches it.