Chat / iOS
Chat iOS v4
Chat iOS
Chat
iOS
Home
/
Chat
/
iOS
/
Notifications
This is the new Docs for Chat SDK v4 for iOS. 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. As for the file_type_friendly, it indicates the type of the file sent, such as Audio, Image, and Video.

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

Text messageFile message

Default template

{sender_name}: {message} An example can be Cindy: Bye!

{filename} An example can be hello_world.jpg

Alternative template

New message arrived

New file arrived

To apply a template to push notifications, use the setPushTemplate(name:completionHandler:) method. Specify the type of the template with the name as either SendbirdChat.PushTemplate.default or SendbirdChat.PushTemplate.alternative.

SendbirdChat.setPushTemplate(name: SendbirdChat.PushTemplate.alternative) { (error) in
    guard error == nil else {
        // Handle error.
        return
    }

    // SendbirdChat.PushTemplate.alternative has been successfully set.
}

You can check the current user's setting with getPushTemplate(completionHandler:) like the following.

SendbirdChat.getPushTemplate { pushTemplate, error in
    guard error == nil else {
        // Handle error.
        return
    }

    if pushTemplate == PushTemplate.default {
        // This sets the default template in use.
    }
    else if pushTemplate == PushTemplate.alternative {
        // This sets the alternative template in use.
    }
}