Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • SystemMessageInterface

Implemented by

Index

Methods

  • deleteAllLocalSysMsgs(options: { done?: any }): void
  • 删除所有本地数据库里的系统通知

    示例

    nim.deleteAllLocalSysMsgs({
    done: function(err) {
    if (err) {
    console.log('删除所有本地系统通知失败', err)
    } else {
    console.log('删除所有本地系统通知成功')
    }
    }
    })

    Parameters

    Returns void

  • deleteLocalSysMsg(options: { idServer: string | string[]; done?: any }): void
  • 删除本地数据库里的系统通知。如果不支持数据库,或指定的通知不存在,算执行成功

    示例场景

    示例

    // 删除单条
    nim.deleteLocalSysMsg({
    idServer: '123456',
    done: function(err) {
    if (err) {
    console.log('删除本地系统通知失败', err)
    } else {
    console.log('删除本地系统通知成功')
    }
    }
    })

    // 删除多条
    nim.deleteLocalSysMsg({
    idServer: ['123456', '789012'],
    done: function(err) {
    if (err) {
    console.log('批量删除本地系统通知失败', err)
    } else {
    console.log('批量删除本地系统通知成功')
    }
    }
    })

    Parameters

    Returns void

  • getLocalSysMsgs(options: { lastIdServer?: string; limit?: number; read?: boolean; reverse?: boolean; type?: "custom" | "addFriend" | "applyFriend" | "passFriendApply" | "rejectFriendApply" | "deleteFriend" | "teamInvite" | "rejectTeamInvite" | "applyTeam" | "rejectTeamApply" | "applySuperTeam" | "rejectSuperTeamApply" | "superTeamInvite" | "rejectSuperTeamInvite" | "deleteMsg"; done?: any }): void
  • 获取本地数据库里的系统通知

    示例场景

    示例

    nim.getLocalSysMsgs({
    type: 'teamInvite',
    read: false,
    limit: 20,
    done: function(err, sysMsgs) {
    if (err) {
    console.log('获取本地系统通知失败', err)
    } else {
    console.log('获取本地系统通知成功', sysMsgs)
    }
    }
    })

    Parameters

    • options: { lastIdServer?: string; limit?: number; read?: boolean; reverse?: boolean; type?: "custom" | "addFriend" | "applyFriend" | "passFriendApply" | "rejectFriendApply" | "deleteFriend" | "teamInvite" | "rejectTeamInvite" | "applyTeam" | "rejectTeamApply" | "applySuperTeam" | "rejectSuperTeamApply" | "superTeamInvite" | "rejectSuperTeamInvite" | "deleteMsg"; done?: any }
      • Optional lastIdServer?: string

        上次查询的最后一条系统通知的 idServer

      • Optional limit?: number

        一页查询数量限制,默认 100

      • Optional read?: boolean

        是否已读.

      • Optional reverse?: boolean

        查询顺序

        默认 false. 表示从最近的系统通知开始往前查找本地系统通知. 若为 true 表示从第一条系统通知开始往后查找本地系统通知

      • Optional type?: "custom" | "addFriend" | "applyFriend" | "passFriendApply" | "rejectFriendApply" | "deleteFriend" | "teamInvite" | "rejectTeamInvite" | "applyTeam" | "rejectTeamApply" | "applySuperTeam" | "rejectSuperTeamApply" | "superTeamInvite" | "rejectSuperTeamInvite" | "deleteMsg"

        类型

      • done?:function

    Returns void

  • 向服务器回包标记系统消息端测已读,下次服务器不需要将此消息作离线系统消息 onofflinesysmsgs 发下来

    标记后会触发 onupdatesysmsgunread 回调

    示例

    nim.markSysMsgRead({
    sysMsgs: [sysMsg1, sysMsg2],
    done: function(err) {
    if (err) {
    console.log('标记系统消息已读失败', err)
    } else {
    console.log('标记系统消息已读成功')
    }
    }
    })

    Parameters

    Returns void

  • sendCustomSysMsg(options: { apnsText?: string; cc?: boolean; content: string; env?: string; isPushable?: boolean; needPushNick?: boolean; pushPayload?: string; scene: "p2p" | "team" | "superTeam"; sendToOnlineUsersOnly?: boolean; to: string; done?: any }): void
  • 发送自定义系统通知

    注,自定义系统通知(sendCustoSysmMsg)和自定义消息(sendCustomMsg)的区别如下:

    1. 自定义消息属于 NIMMessage, 会存储在云信服务器消息数据库中, 与其他消息一同传递给开发者,可以查询历史消息,。
    2. 自定义系统通知属于 NIMSystemMessage, 用于第三方通知端侧, 不会存储在云信服务器数据库中,无法查询历史消息。SDK 仅仅负责传递这些通知。

    示例场景

    示例

    // 发送"正在输入"提示
    nim.sendCustomSysMsg({
    scene: 'p2p',
    to: 'user1',
    content: JSON.stringify({ type: 'typing' }),
    sendToOnlineUsersOnly: true,
    isPushable: false,
    done: function(err, sysMsg) {
    if (err) {
    console.log('发送自定义系统通知失败', err)
    } else {
    console.log('发送自定义系统通知成功', sysMsg)
    }
    }
    })

    Parameters

    • options: { apnsText?: string; cc?: boolean; content: string; env?: string; isPushable?: boolean; needPushNick?: boolean; pushPayload?: string; scene: "p2p" | "team" | "superTeam"; sendToOnlineUsersOnly?: boolean; to: string; done?: any }
      • Optional apnsText?: string

        apns推送文案, 仅对接收方为iOS设备有效

      • Optional cc?: boolean

        是否抄送. 默认 true

      • content: string

        自定义系统消息的内容,推荐传入 JSON 序列化字符串。

      • Optional env?: string

        环境变量,用于指向不同的抄送、第三方回调等配置

      • Optional isPushable?: boolean

        是否需要推送. 默认 true

      • Optional needPushNick?: boolean

        是否需要推送昵称. 默认 false

      • Optional pushPayload?: string

        自定义系统通知的推送属性. 推荐传入 JSON 序列化字符串

      • scene: "p2p" | "team" | "superTeam"

        场景,跟消息场景的一样分为 p2p, team, superTeam.

      • Optional sendToOnlineUsersOnly?: boolean

        是否只发送给在线用户. 默认为 true

        true. 只发送给在线用户, 如果接收方不在线, 这条通知将被丢弃。适合是“正在输入”这种场景

        false. 若接收方在线, 那么会立即收到该通知,若接收方不在线, 会在其上线后推送离线系统通知。

      • to: string

        接收方,account ID,或者群号。

      • done?:function

    Returns void

  • updateLocalSysMsg(options: { idServer: string; localCustom?: string; state?: string; done?: any }): void
  • 更新本地数据库里的系统通知

    示例

    nim.updateLocalSysMsg({
    idServer: '123456',
    state: 'passed',
    localCustom: JSON.stringify({ handled: true }),
    done: function(err, sysMsg) {
    if (err) {
    console.log('更新本地系统通知失败', err)
    } else {
    console.log('更新本地系统通知成功', sysMsg)
    }
    }
    })

    Parameters

    Returns void