Push notification content templates
Push notification content templates are pre-formatted forms that can be customized to display your own push notification messages on a user’s device. Sendbird provides two types: default and alternative. Both templates can be customized in Settings > Chat > Push notifications > Push notification content templates on Sendbird Dashboard.
As for Android, an additional implementation is required in order to display your customized push notifications. The push notification payload sent from the Sendbird server includes the content of the template, such as the title and message, and the client app can determine how to present the notification through Android-provided code. For more information on how to create a custom notification, refer to Notifications in Android's Documentation for app developers.
Huawei Mobile Service (HMS) also requires an additional implementation for custom push notifications. To learn more, see Push Kit at Huawei's Documentation.
Content templates
There are two types of push notification content template: default and alternative. Default template is a template that applies to users with the initial notification message setting. Alternative template is used when a user selects a different notification content template instead of the default template.
The content in the template is set at the application level while the selection of templates is determined by a user or through the Platform API.
Note: When a custom channel type has its own customized push notification content template, it takes precedence over the default or alternative template.
Both templates can be customized using the variables of sender_name
, filename
, message
, channel_name
, and file_type_friendly
which are replaced with the corresponding string values. As for file_type_friendly
, it indicates the type of the file sent, such as Audio, Image, and Video.
See the following table for the usage of content templates.
List of content templates
Text message | File message | |
---|---|---|
Default template | {sender_name}: {message} | {filename} |
Alternative template |
|
|
To apply a template to push notifications, use the setPushTemplate()
method. Specify the type of the template with the name as either SendbirdChat.PUSH_TEMPLATE_DEFAULT
or SendbirdChat.PUSH_TEMPLATE_ALTERNATIVE
.
To check the current user's push notification template, use the getPushTemplate()
method as follows: