Overview
Using Chat SDK for Android, you can send notification messages to your user's device when the device is either idle or running the client app in the background. For group channels, notifications can be configured to display an alert, play a sound, or place a badge on the client app's icon.
Push notifications for Android client apps are sent using Firebase Cloud Messaging (FCM) or Huawei Mobile Service (HMS) which contains custom data that your app needs in order to respond to the notifications. When a message is sent to the Sendbird server through our Chat SDK, the server communicates with FCM or HMS which then delivers a push notification to an Android device where the client app is installed.
By default, when a user's device is disconnected from the Sendbird server, the server sends push notification requests to FCM for the messages. The Chat SDK automatically detects when a user's client app goes into the background from the foreground, and updates the user's connection status to disconnected. Therefore, under normal circumstances, there is no need to explicitly call the disconnect()
method.
Push notifications support both single and multi-device users and they are delivered only when a user is fully offline from all of their devices. In other words, if a user is online on one or more devices, notifications aren't delivered and thus not displayed on any device.
Push notification with multi-device support
Push notifications with multi-device support provide the same features as our general push notifications, but with additional support for multi-device users. When implemented, notifications are delivered to all online and offline devices of a multi-device user but through our Chat SDK, push notifications are displayed only on offline devices and ignored by online devices. As a result, client apps are able to display push notifications on all offline devices, regardless of whether there are one or more online devices.
For example, let’s say a multi-device user who has six devices with your client app installed is online on one of the devices and offline on the remaining five. When general push notifications are implemented, notifications aren’t delivered to any of their devices. But when push notifications with multi-device support are implemented, notifications are delivered to all six devices and displayed on the five offline devices.
By default, when a user's device is disconnected from the Sendbird server, the server sends push notification requests to FCM for the messages. The Chat SDK automatically detects when a user's client app goes into the background from the foreground, and updates the user's connection status to disconnected. Therefore, under normal circumstances, there is no need to call the disconnect()
method.
To find out which type of push notification best fits your use case, see the following table.
General push notifications | Push notifications with multi-device support | |
---|---|---|
Sent when | All devices are offline. | At least one device is offline. |
Notification messages | Single-device user: Displayed when disconnected from the Sendbird server and thus offline. | Single-device user: Displayed when disconnected from the Sendbird server and thus offline. |
SDK's event callback | Invoked only when the app is connected to the Sendbird server. | Invoked only when the app is connected to the Sendbird server. |
App instance's registration token | Can be manually registered to the Sendbird server. | Automatically registered to the Sendbird server. |
Notification preferences | Can be set by application and group channel. | N/A |
Push notification templates | Supported. | Supported. |
Push notification translation | Supported by Google Cloud Translation API. | Supported by Google Cloud Translation API. |
Functionalities by topic
Users can set their preferences for receiving notifications in their devices. The following is a list of functionalities that our Chat SDK provides.
Managing notifications
Functionality | Description | Open channel | Group channel |
---|---|---|---|
Users can receive FCM messages in their Android app. | |||
Users can receive push notifications on HMS. | |||
Turns push notifications on or off in a user's app using the user's registration token. | |||
Displays customized push notification messages on a user's device using templates. | |||
Test on Sendbird Dashboard whether the push notification credentials and notification services are working properly. | |||
Users can receive notification messages translated into their preferred languages. |
Additional support for multi-device users
Functionality | Description | Open channel | Group channel |
---|---|---|---|
Multi-device users can receive FCM messages on multiple devices. | |||
Multi-device users can receive HMS notification messages on multiple devices. |