差别
这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录 前一修订版 后一修订版 | 前一修订版 后一修订版 两侧同时换到之后的修订记录 | ||
im:other:integrationcases:snapchat [2018/09/25 10:39] jk |
im:other:integrationcases:snapchat [2021/06/15 06:33] zhangdong [接收阅后即焚消息,查看后发送回执并删除本地消息] |
||
---|---|---|---|
行 52: | 行 52: | ||
</code> | </code> | ||
+ | === web/小程序示例 === | ||
+ | <code> | ||
+ | let id = conn.getUniqueId(); // 生成本地消息id | ||
+ | let msg = new WebIM.message('txt', id); // 创建文本消息 | ||
+ | msg.set({ | ||
+ | msg: '这是一条阅后即焚消息', // 消息内容 | ||
+ | to: 'username', // 接收消息对象(用户id) | ||
+ | chatType: 'singleChat', // 设置为单聊 | ||
+ | ext: {fire: true}, // 消息扩展,标记为阅后即焚 | ||
+ | success: function (id, serverMsgId) {}, | ||
+ | fail: function(e){} | ||
+ | }); | ||
+ | conn.send(msg.body); | ||
+ | </code> | ||
===== 接收阅后即焚消息,查看后发送回执并删除本地消息 ===== | ===== 接收阅后即焚消息,查看后发送回执并删除本地消息 ===== | ||
行 109: | 行 123: | ||
</code> | </code> | ||
+ | === web/小程序示例 === | ||
+ | <code> | ||
+ | /** | ||
+ | * 新消息回调 | ||
+ | */ | ||
+ | onTextMessage(message){ | ||
+ | // 判断是否为阅后即焚消息 | ||
+ | if(message.ext.fire){ | ||
+ | // update ui | ||
+ | } | ||
+ | } | ||
+ | |||
+ | // 当用户已经读取过消息后,发送已读回执并删除本地消息 | ||
+ | var msgId = message.id; // 需要发送已读回执的消息id | ||
+ | var msg = new WebIM.message('read', conn.getUniqueId()); // 已读回执消息 | ||
+ | msg.set({ | ||
+ | id: msgId, | ||
+ | to: message.from | ||
+ | }); | ||
+ | conn.send(msg.body); | ||
+ | |||
+ | </code> | ||
===== 消息发送方收到回执,判断需要焚毁,删除本地消息 ===== | ===== 消息发送方收到回执,判断需要焚毁,删除本地消息 ===== | ||
行 156: | 行 192: | ||
<WRAP half column> | <WRAP half column> | ||
- | 下一页:[[im:other:integrationcases:revokemessages|消息回撤]] | + | 下一页:[[im:other:integrationcases:revokemessages|消息撤回]] |
</WRAP> | </WRAP> | ||
</WRAP> | </WRAP> | ||