open.shareAppMessage

在轻应用内部调起会话列表,并分享消息至会话。

注意

insight.open.shareAppMessage 自 SDK 版本 1.4.3,iOS 客户端 5.4.910 ,Android 客户端暂不支持,PC 客户端 5.6.403 及以上版本支持。

disableForward 参数 自 SDK 版本 1.4.5,iOS 客户端 5.5.706 ,Android 客户端暂不支持 ,PC 客户端 5.11.3 及以上版本支持。

insight.open.shareAppMessage(options).then().catch()

options 参数说明

父参数 名称 类型 必填 描述
msgType String 是 消息类型,link > 卡片消息;hdrive > 文件消息
msg Object 是 消息体,具体参数说明
to Object 否 消息接收方信息,传则将消息转发到指定接收方,否则弹出选择联系人列表
to type String 是 会话类型,group > 群聊;private > 单聊
to id String 是 会话id,type == group时,为群聊的groupId;type == private时,为单聊的openId
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="shareAppMessage">shareAppMessage</button>
<script>
    document.getElementById("shareAppMessage").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.shareAppMessage(msgType, msg, to)
            .then(data => {
                alert(JSON.stringify(data));
            })
            .catch(error => {
                alert(JSON.stringify(error));
            })
    }, false);
    document.getElementById("shareAppMessage").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.shareAppMessage(msgType, msg, to)
            .then(data => {
                alert(JSON.stringify(data));
            })
            .catch(error => {
                alert(JSON.stringify(error));
            })
    }, false);
</script>