Overview
Chat supports integration of Google Firebase Cloud Messaging (FCM), which enables developers to use an offline push notification service. The service features low latency, high delivery, high concurrency, and no violation of the users' personal data.
When a user goes offline because of client disconnection or the app process closing, Chat will push notifications to the offline user's device through the FCM message push service.
When the user is online again, the server will send the messages received while they were offline.
For example, when you are offline and another user sends you a message, a notification will pop up on your phone. When you open the app and log in successfully, Chat will actively pull the messages sent when you were offline.
If the app is running in the background and the user is still online, Chat will not push notifications. When multiple devices are logged in, you can configure the push certificate page in the Agora Console to send push notifications when either all or some of them are offline. This configuration is effective for all push channels.
To use FCM offline push, configure the FCM push certificate information, such as Private Key and Certificate Name in Agora Console. Then call the API provided by the client SDK to upload the device token to the Agora server.
To test the offline push feature, download our demo.
Understand the tech
The following figure shows the basic workflow of offline push:
- User B initializes the FCM push SDK and checks whether FCM push is configured.
- User B obtains the device token from the FCM push server according to the configured FCM push SDK.
- The FCM push server returns the device token to user B.
- User B uploads the push certificate name and device token to the Agora Chat server.
- User A sends a message to User B.
- The Agora Chat server checks whether user B is online. If so, the server directly sends the message to user B.
- If user B is offline, the Agora server determines whether the user has configured FCM push.
- The Agora server sends the message to the FCM push server.
- The FCM push server sends the message to user B.