Configure push notifications

Updated

Configure push translations

You can use extension fields to implement force push and send silent messages. For more information, see Offline push notification extension.

Force push

The user can set force push to ignore the recipient's DND setting when sending messages:

// The following takes text messages as an example. The setting methods for other types of messages are the same.
const sendTextMsg = () => {
  const options: AgoraChat.CreateTextMsgParameters = {
    chatType: chatType,
    type: "txt",
    to: targetUserId,
    msg: msgContent,
    ext: {
      // Set whether to force push. This field is a built-in field with the following values: `YES`: force push; (default) `NO`: non-force push.
      em_force_notification: "YES",
    },
  };
  const msg = AgoraChat.message.create(options);
  chatClient.send(msg);
};

Send a silent message

A silent message means that when a user is offline, Chat will not push notifications to the user's device through the push service. Therefore, the user will not receive message push notifications. When the user is online again, they will receive all the messages received during the offline period.

Both silent message sending and do not disturb mode pause push messages. The difference is that silent message sending is set by the sender when sending the message, while do not disturb mode is set by the receiver.

// The following takes text messages as an example. The setting methods for other types of messages are the same.
const sendTextMsg = () => {
  const options: AgoraChat.CreateTextMsgParameters = {
    chatType: chatType,
    type: "txt",
    to: targetUserId,
    msg: msgContent,
    ext: {
      // Set whether to send silent messages. This field is a built-in field with the following values: `YES`: send silent messages; (default) `NO`: push the message.
      em_ignore_notification: "NO",
    },
  };
  const msg = AgoraChat.message.create(options);
  chatClient.send(msg);
};