Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ISendCustomMsgOptions

Hierarchy

Index

Properties

antiSpamInfo?: TMsgAntiSpamInfo

反垃圾相关配置

attach: string
body?: string

文本消息内容。

callbackExt?: string

第三方回调的扩展字段

ext?: string

扩展字段。消息发送后,消息体中的 ext 属性等于发送消息时设置的 ext属性值

idClient?: string

消息客户端唯一标识。只在于重发时可以指定

pushInfo?: TMsgPushInfo

推送相关配置

replyMsg?: IMMessage

回复消息时,可以设置 replyMsg。设置回复消息后,后续可通过消息扩展接口查询消息的回复关系。请参考文档:消息扩展

example
// 回复消息
nim.msg.sendText({
scene: 'p2p',
to: 'test',
text: 'reply hello world',
replyMsg: msg,
done: (e, r) => console.log(e ? '发送消息失败' : '发送消息成功')
})

// 输入根消息节点,查询该消息所有的回复消息
const res = await nim.msgExtend.getThreadMsgs({
"scene": "p2p",
"threadMsgFromAccount": "zk1",
"threadMsgIdServer": rootMsg.idServer,
"threadMsgTime": rootMsg.time,
"threadMsgToAccount": "zk2",
"limit": 100,
"reverse": false
})
scene: "p2p" | "team" | "superTeam"

场景

  • 'p2p' (单人聊天)
  • 'team' (群聊)
  • 'superTeam' (超大群聊天)
setting?: TMsgSetting

消息的杂项设置

subType?: number

消息子类型,格式为大于0的整数,开发者可自定义

teamSpecializationInfo?: Pick<TMsgTeamSpecializationInfo, "needACK">

群组特化的杂项配置。

发送消息时,仅支持设置 needACK 属性

to: string

接收方, 对方帐号或者群id

Methods

  • 发送前的回调函数,用于发送前拿到这个消息对象

    • 此时这个消息对象还没有 idServer 和准确的 time,并且 status 也只是在 sending
    • 发送失败时,可以用该回调保存消息,然后调用 MsgServiceInterface.resendMsg 重发
    example
    try {
    let tempMsg
    await nim.msg.sendTextMsg({
    scene: 'p2p',
    to: 'test',
    body: 'message',
    onSendBefore: (msg) => {
    // 发送消息前,通过该回调临时存储消息
    tempMsg = msg
    }
    })
    } catch(err) {
    // 发送失败
    tempMsg.status = 'sendFailed'
    }

    // 如果发送失败,调用 resendMsg 重发消息
    nim.msg.resendMsg({
    msg: tempMsg
    })

    Parameters

    Returns void