Offline Push
Application Scenarios
You can use the offline push feature to allow users to receive new messages even when the app is running in the background or the process has been killed. iOS devices use APNs for offline push, while Android devices need you to register for offline message callbacks.
iOS APNs Push Notifications
Push notification format
The figure shows the examples of a one-to-one chat message and group chat message.
For more information about iOS APNs push formats, see Push Format.
Basic APIs
The following APIs must be called to support APNs. For more information, see iOS APNs Event Reporting:
Set the token.
Switch to the background and report unread messages.
Switch to the foreground and push notifications.
Setting the Ext extension field
In some cases, an app needs to set the Ext extension field for offline push based on specific circumstances to facilitate user operations such as redirect clicks. You can input it into the Ext field in TIMCustomElem, and during push, the IM backend will input the field into Ext. For more information, see Customizing Offline Message Attributes to customize the extension field.
Setting push alert sounds
In some cases, an app needs to set the push alert sound of a single message to alert users. You can input the sound into the sound field in TIMCustomElem, and during push, the IM backend will input the field into Ext. For more information, see Setting Custom Push Alert Sounds.
Android Offline Push
Android 1.8.0 and later versions support separating services from processes. When the app process is killed, the service survives and continues to receive offline notifications. For more information, see Android Offline Push.
Sending Messages from the Backend
For iOS, you can refer to Push Format to set the display format of APNs push messages; for Android, you can refer to OfflinePushInfo to set the display format.