open.sendChatMessage

在当前会话中使用轻应用分享消息到当前会话。

注意

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()

options 参数说明

名称 类型 必填 描述
msgType String 消息类型,link > 卡片消息;hdrive > 文件消息
msg Object 消息体,具体参数说明
disableForward Boolean true / false 此消息是否禁止转发,默认为false

msgType 参数说明

名称 类型 必填 描述
url String 消息链接
title String 消息标题
content String 消息内容摘要
imageUrl String 消息封面图链接

msgType == hdrive

名称 类型 必填 描述
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>