消息接收选项 | 功能描述 |
在线时正常接收消息,离线时接收离线推送通知 | |
SDK 接收消息并通知接入侧(抛出 收到消息事件),接入侧不做提示,一般用于实现“消息免打扰” | |
SDK 拒收消息 |
chat.setMessageRemindType(options);
Name | Type | Description |
groupID | String | 群 ID 或 话题 ID |
userIDList | Array | C2C 会话对端 userID 列表,单次请求的 userID 数不得超过30 |
messageRemindType | String | 群消息提示类型。详细如下: TencentCloudChat.TYPES.MSG_REMIND_ACPT_AND_NOTE (SDK 接收消息并通知接入侧(抛出 MESSAGE_RECEIVED 事件),接入侧做提示)TencentCloudChat.TYPES.MSG_REMIND_ACPT_NOT_NOTE (SDK 接收消息并通知接入侧(抛出 MESSAGE_RECEIVED 事件),接入侧不做提示,一般用于实现“消息免打扰”)TencentCloudChat.TYPES.MSG_REMIND_DISCARD (SDK 拒收消息) |
Promise
// 拒收群消息(通过 getMessageList 接口可拉取到其他群成员发送的消息)let promise = chat.setMessageRemindType({groupID: 'group1',messageRemindType: TencentCloudChat.TYPES.MSG_REMIND_DISCARD});promise.then(function(imResponse) {// 设置成功后 SDK 会触发 TencentCloudChat.EVENT.CONVERSATION_LIST_UPDATED 事件// (遍历列表,并读取 Conversation.messageRemindType)}).catch(function(imError) {console.warn('setMessageRemindType error:', imError);});
// 拒收群消息后,重新开启新消息提醒let promise = chat.setMessageRemindType({groupID: 'group1',messageRemindType: TencentCloudChat.TYPES.MSG_REMIND_ACPT_AND_NOTE});promise.then(function(imResponse) {// 设置成功后 SDK 会触发 TencentCloudChat.EVENT.CONVERSATION_LIST_UPDATED 事件// (遍历列表,并读取 Conversation.messageRemindType)}).catch(function(imError) {console.warn('setMessageRemindType error:', imError);});
// C2C 消息免打扰,一般的实现是在线接收消息,离线不接收消息(在有离线推送的情况下)let promise = chat.setMessageRemindType({userIDList: ['user1', 'user2'],messageRemindType: TencentCloudChat.TYPES.MSG_REMIND_ACPT_NOT_NOTE});promise.then(function(imResponse) {// 设置成功后 SDK 会触发 TencentCloudChat.EVENT.CONVERSATION_LIST_UPDATED 事件//(遍历列表,并读取 Conversation.messageRemindType)const { successUserIDList, failureUserIDList } = imResponse.data;// 删除成功的 userIDListsuccessUserIDList.forEach((item) => {const { userID } = item;});// 删除失败的 userIDListfailureUserIDList.forEach((item) => {const { userID, code, message } = item;});}).catch(function(imError) {console.warn('setMessageRemindType error:', imError);});
// 群消息免打扰,一般的实现是在线接收消息,离线不接收消息(在有离线推送的情况下)let promise = chat.setMessageRemindType({groupID: 'group1',messageRemindType: TencentCloudChat.TYPES.MSG_REMIND_ACPT_NOT_NOTE});promise.then(function(imResponse) {// 设置消息免打扰成功}).catch(function(imError) {// 设置消息免打扰失败console.warn('setMessageRemindType error:', imError);});
// 社群话题消息免打扰,一般的实现是在线接收消息,离线不接收消息(在有离线推送的情况下)let promise = chat.setMessageRemindType({groupID: 'topicID',messageRemindType: TencentCloudChat.TYPES.MSG_REMIND_ACPT_NOT_NOTE});promise.then(function(imResponse) {// 设置消息免打扰成功}).catch(function(imError) {// 设置消息免打扰失败console.warn('setMessageRemindType error:', imError);});
本页内容是否解决了您的问题?