外观
转发消息
约 274 字小于 1 分钟
2025-12-16
说明
1、此API需要SDK版本 >= 1.3.5;
2、单次可以转发的消息数量最大为 50 条;
3、单次可以转发的用户数和群聊数最多为 10 个。
1. 描述
forwardMessage() 转发消息给其他用户或发送到指定邮箱,该方法为异步函数,会返回一个Promise对象。
2. 参数
| 参数名称 | 是否必选 | 类型 | 说明 |
|---|---|---|---|
| type | 是 | String | 转发类型,可选:chat-消息,email-邮件 |
| messageList | 是 | Array | 完整的消息列表 |
| 否 | Array | 邮箱地址数组,type为email时必填 | |
| userIds | 否 | Array | 用户ID(IM系统用户ID),type为chat时必填 |
| groupIds | 否 | Array | 群聊ID(IM系统群聊ID),type为chat时必填 |
3. 返回值
返回一个 Promise 对象。
4. 示例代码
// 转发消息给其他用户
XBCIM.forwardMessage({
type: 'chat',
userIds: ['user1', 'user2'],
groupIds: ['group1', 'group2'],
messageList: ['message1', 'message2']
}).then(() => {
console.log('消息转发成功')
}).catch(() => {
console.log('消息转发失败')
})
// 转发消息到邮件
XBCIM.forwardMessage({
type: 'email',
email: ['email1', 'email2']
}).then(() => {
console.log('消息转发成功')
}).catch(() => {
console.log('消息转发失败')
})