提交工单
咨询集成、功能及报价等问题
If a user is logged in on multiple platforms, the user can configure custom push rules to specify the platforms that can or cannot receive offline push notifications.
Before you implement the custom push rule
feature, make sure that the following conditions are met:
To receive the notification for custom rule update, register the (userRuleUpdated) event.
// Listen for custom rules.
zim.on('userRuleUpdated', (zim, data) => {
// Offline push rules.
const offlinePushRule = data.userRule.offlinePushRule;
});
To support custom push rules, build the ZIMUserOfflinePushRule class to specify the platforms that do not receive offline push notifications(notToReceiveOfflinePushPlatforms)when the user is online on specified platforms(onlinePlatforms).
To set the above rules, call the updateUserOfflinePushRule method.
// Set offline push rules.
var offlinePushRule = {
// The user is logged in to Windows, macOS, and Linux platforms.
onlinePlatforms: [1, 4, 5],
// The user receives no offline push on the iPhoneOS, iPadOS, and Android platforms.
notToReceiveOfflinePushPlatforms: [2, 3, 9],
};
zim.updateUserOfflinePushRule(offlinePushRule)
.then((res) => {
// success
})
.catch((err) => {
// error
});
Call the querySelfUserInfo method to obtain the current custom offline push rules.
zim.querySelfUserInfo().then((res) => {
const { offlinePushRule } = res.selfUserInfo.userRule;
});