/ SDKs / JavaScript
SDKs
Chat SDKs JavaScript v4
Chat SDKs JavaScript
Chat SDKs
JavaScript
Version 4

Push notification content templates

Copy link

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.


Content templates

Copy link

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 sent to those who opted to a different notification message setting.

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 templates.

Both templates can be customized using the variables of sender_name, filename, message, channel_name, and file_type_friendly which will be replaced with the corresponding string values. The file_type_friendly field indicates the type of the file sent, such as Audio, Image, and Video.


Refer to the following table for the usage of content templates.

Content templates use cases

Copy link
Text messageFile message

DEFAULT

{sender_name}: {message}
An example can be Cindy: Hi!.

{filename}
An example can be hello_world.jpg.

ALTERNATIVE

New message arrived

New file arrived

To apply a template to push notifications, use the setPushTemplate() method. Specify the template name as either with PushTemplate.DEFAULT or PushTemplate.ALTERNATIVE.

JavaScriptTypeScript
await sb.setPushTemplate(PushTemplate.ALTERNATIVE);

To check the current user's push notification template, use the getPushTemplate() method like the following.

JavaScriptTypeScript
const pushTemplate = await sb.getPushTemplate();