Skip to main content
Android
iOS
Web
Windows
Unity
Flutter
React Native

Offline push notification extension

Agora Chat supports APNs and FCM push integration. When using offline push, you can configure push functions using message extension fields. For example, you can set the push title and content in a push template or configure personalized push notifications for specific users in a group.

Push extension fields

payload.ext contains the following fields:

FieldTypeDescription
em_push_filterObjectThe push filter.
em_push_templateObjectThe push template.
em_ignore_notificationBooleanWhether to send a silent message.
- true: No notification is sent to offline users.
- false: A notification is sent to offline users.
em_force_notificationBooleanWhether to push notifications even if the recipient is in Do Not Disturb (DND) mode.
- true: Notifications are pushed.
- false: Notifications are not pushed.
em_apns_extObjectAPNs push extension settings.
em_android_push_extObjectAndroid push extension settings.
em_push_extObjectCommon push extension settings.

em_push_filter fields

FieldTypeDescription
accept_device_idList<String>List of device IDs that receive push notifications.
ignore_device_idList<String>List of device IDs that do not receive push notifications.
accept_notifier_nameList<String>List of push certificates of users who receive push notifications.
ignore_notifier_nameList<String>List of push certificates of users who do not receive push notifications.

em_push_template fields

FieldTypeDescription
nameStringThe push template name.
title_argsList<String>The push template title, which can include embedded parameters such as {$fromNickname} (sender's nickname).
content_argsList<String>The push template content, which can include embedded parameters such as {$msg} (message content). If translation is enabled, both the original message and the translation appear in the push notification.
directed_templateObjectA targeted push template. This applies to group messages where different push notifications are sent to different users.

directed_template fields

FieldTypeDescription
targetArray<String>List of user IDs. User IDs must contain only lowercase letters.
nameStringThe push template name.
title_argsArray<String>The push template title.
content_argsArray<String>The push template content.

em_push_ext fields

FieldTypeDescription
titleStringCustom push title.
contentStringCustom push content.
customObjectUser-defined extension field. Matches the e field among other parsed fields (t, f, m, and g) when receiving a push notification.
group_user_nicknameStringNickname of the sender's group.
typeStringVoIP push notification (only applicable when APNs supports VoIP notifications).

em_apns_ext fields (APNs)

FieldTypeDescription
em_push_categoryStringPush notification category.
em_push_mutable_contentBooleanWhether the notification supports rich text.
- true: Rich text notification.
- false: Standard notification.
em_push_soundStringCustom ringtone file in Library/Sounds/, such as appsound.caf.
em_push_badgeIntegerCustom badge number.
em_push_content_availableIntegerBackground notification indicator. For details, see Apple's documentation.

em_android_push_ext fields (Android)

FieldTypeDescription
fcm_optionsObjectFCM SDK options.
fcm_channel_idStringFCM channel ID (with the highest priority).

Example

Push extension fields structure


_35
{
_35
"ext": {
_35
"em_push_filter": {
_35
"accept_device_id": [],
_35
"ignore_device_id": [],
_35
"accept_notifier_name": [],
_35
"ignore_notifier_name": []
_35
},
_35
"em_at_list": ["abc"],
_35
"em_push_template": {
_35
"name": "test6",
_35
"title_args": ["test1"],
_35
"content_args": ["{$fromNickname}", "{$msg}"]
_35
},
_35
"em_push_ext": {
_35
"custom": {"test": 1},
_35
"group_user_nickname": "happy"
_35
},
_35
"em_ignore_notification": false,
_35
"em_force_notification": true,
_35
"em_apns_ext": {
_35
"em_push_title": "You've got a new message",
_35
"em_push_content": "Please click to view",
_35
"em_push_category": "",
_35
"em_push_mutable_content": true,
_35
"em_push_sound": "appsound.mp3",
_35
"em_push_badge": 1,
_35
"em_push_content_available": 1
_35
},
_35
"em_android_push_ext": {
_35
"fcm_options": {"key": "value"},
_35
"fcm_channel_id": ""
_35
}
_35
}
_35
}

Targeted push template

Use targeting templates to send different notifications to a specific user in a group than to other group members.

Step 1: Create a Push Template


_5
{
_5
"name": "at_push_template",
_5
"title_pattern": "{0}",
_5
"content_pattern": "{0}:{1}"
_5
}

Step 2: Apply the template for group messages

User hxtest receives the push notification "Tom mentions you in the group", while other offline users receive "Tom sends a message".


_13
{
_13
"em_push_template": {
_13
"name": "push_template",
_13
"title_args": ["group name"],
_13
"content_args": ["Tom", "sends a message"],
_13
"directed_template": {
_13
"target": ["hxtest"],
_13
"name": "at_push_template",
_13
"title_args": ["group name"],
_13
"content_args": ["Tom", "mentions you in the group"]
_13
}
_13
}
_13
}

Additional push configuration

For users other than the mentioned user, you don’t need to use a template for push content. Instead, you can customize the title and content using push extension fields:

  • Title: The name of the group.
  • Content: A brief message indicating an action, such as "sends a message."

_15
{
_15
"em_push_template": {
_15
"directed_template": {
_15
"target": ["hxtest"],
_15
"name": "at_push_template",
_15
"title_args": ["group name"],
_15
"content_args": ["Tom", "mentions you in the group"]
_15
}
_15
},
_15
"em_push_ext": {
_15
"title": "group name",
_15
"content": "sends a message",
_15
"type": "call"
_15
}
_15
}

vundefined