打开指定用户或群的聊天页面。
注意
insight.open.enterChat 自 SDK 版本 1.4.5,iOS 客户端 5.5.706 ,Android 客户端与 PC 客户端暂不支持。
insight.open.enterChat(options).then().catch()
名称 | 类型 | 必填 | 描述 |
---|---|---|---|
type | String | 是 | 聊天类型:group(群聊)、private(单聊) |
id | String | 是 | 当type为group时,传群id;type为private时,传用户open_id |
错误码说明
code | msg |
---|---|
0 | 成功 |
1 | 当type为group时,群ID为空;type为private时,用户open_id为空 |
2 | 当type为group时,群不存在;type为private时,用户不存在 |
3 | 不是群成员 |
4 | 网络问题。当type为group时,群profile请求失败;type为private时,用户profile请求失败 |
5 | 其他 |
<button id="enterChat">enterChat</button>
<script>
document.getElementById("enterChat").addEventListener('click', function(e) {
var type = 'group',
id = 1
insight.open.enterChat(type, id)
.then(data => {
alert(JSON.stringify(data));
})
.catch(error => {
alert(JSON.stringify(error));
})
}, false);
</script>