Chat / JavaScript
Chat JavaScript v4
Chat JavaScript
Chat
JavaScript
Home
/
Chat
/
JavaScript
/
Notifications
This is the new Docs for Chat SDK v4 for JavaScript. To see the previous Docs, click here.

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 > Application > Notifications > Push notification content templates on the Sendbird Dashboard.


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

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.

await sb.setPushTemplate(PushTemplate.ALTERNATIVE);

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

const pushTemplate: PushTemplate = await sb.getPushTemplate();