在当前会话中使用轻应用分享消息到当前会话。
注意
insight.open.sendChatMessage 自 SDK 版本 1.4.3,iOS 客户端 5.4.910 ,Android 客户端暂不支持,PC客户端 5.5.319 及以上版本支持。
disableForward 参数 自 SDK 版本 1.4.5,iOS 客户端 5.5.706 ,Android 客户端暂不支持 ,PC 客户端 5.11.3 及以上版本支持。
insight.open.sendChatMessage(options).then().catch()
名称 | 类型 | 必填 | 描述 |
---|---|---|---|
msgType | String | 是 | 消息类型,link > 卡片消息;hdrive > 文件消息 |
msg | Object | 是 | 消息体,具体参数说明 |
disableForward | Boolean | 否 | true / false 此消息是否禁止转发,默认为false |
名称 | 类型 | 必填 | 描述 |
---|---|---|---|
url | String | 是 | 消息链接 |
title | String | 否 | 消息标题 |
content | String | 否 | 消息内容摘要 |
imageUrl | String | 否 | 消息封面图链接 |
名称 | 类型 | 必填 | 描述 |
---|---|---|---|
fileType | String | 是 | 文件类型 |
fileName | String | 是 | 文件名 |
fileSize | Number | 是 | 文件大小 |
createdBy | String | 否 | OneDrive类型下展示文件owner信息 |
driveId | String | 是 | 文件唯一driveId |
itemId | String | 是 | 文件唯一itemId |
webUrl | String | 是 | PC端打开文件跳转至浏览器的url链接 |
url | String | 是 | mob端打开文件H5预览的轻应用链接信息 |
parentItemId | String | 是 | 文件所在目录唯一Id |
ownerUshuOpenId | String | 否 | 文件所属人的openId |
contentType | String | 否 | 文件的ContentType |
<button id="sendChatMessage">sendChatMessage</button>
<script>
document.getElementById("sendChatMessage").addEventListener('click', function(e) {
var msgType = 'link',
msg = {
url: 'https://xx.com',
title: 'xx',
content: 'xxxx',
imageUrl: 'https:xx.png'
},
to = {
type: 'private',
id: '123'
}
insight.open.sendChatMessage(msgType, msg, to)
.then(data => {
alert(JSON.stringify(data));
})
.catch(error => {
alert(JSON.stringify(error));
})
}, false);
document.getElementById("sendChatMessage").addEventListener('click', function(e) {
var msgType = 'hdrive',
msg = {
fileType: "SharePoint",
fileName: "工作簿1.xlsx",
fileSize: 123,
createdBy: "xxx",
driveId: "xxx",
itemId: "xxx",
webUrl: "https://xx.com",
url: "xxxx",
parentItemId: "xxx",
parentUrl: "xxx"
},
to = {
type: 'private',
id: '123'
}
insight.open.sendChatMessage(msgType, msg, to)
.then(data => {
alert(JSON.stringify(data));
})
.catch(error => {
alert(JSON.stringify(error));
})
}, false);
</script>