Options
All
  • Public
  • Public/Protected
  • All
Menu

Class NIM

Hierarchy

Implements

Index

Constructors

Methods

Constructors

Methods

  • acceptSuperTeamInvite(_options: { from: string; idServer: string; teamId: string; done?: any }): void
  • accept an invitation to join the group SuperTeamInterface.addSuperTeamMembers

    Group owners and administrators invite users to join the group ({@link TeamInterface.addSuperTeamMembers | addSuperTeamMembers}), and the invited users will receive a system notification of type superTeamInvite.

    • If a user accepts the invitation to join the group, all members of the group will receive a group notification of type acceptSuperTeamInvite, the specific content of the notification message is as follows.
    • If a user rejects the invitation, the person who sent the invitation will receive a system notification of type rejectSuperTeamInvite, the value of the from field is the account ID of the user who rejects the invitation, and the value of the to field is the group ID

    If a user accepts an invitation to join a group,

    1. All group members (except the sender) receive the group notification: onmsg:
      • msg.type: 'notification'
      • msg.from: Inviter account
      • msg.to: Group ID
      • msg.attach.type: 'acceptSuperTeamInvite'
      • msg.attach.team: Group information
      • msg.attach.members: List of members who accept the invitation
    2. All group members get notified by onupdatesessions
    3. All group members get notified by onAddSuperTeamMembers
    4. The function call triggers onupdatesysmsg

    Associated function

    Parameters

    • _options: { from: string; idServer: string; teamId: string; done?: any }
      • from: string

        accountId of the requester

      • idServer: string

        idServer of the notification for invitation from an administrator.

      • teamId: string
      • done?:function

    Returns void

  • acceptTeamInvite(_options: { from: string; idServer: string; teamId: string; done?: any }): void
  • accept an invitation to join the group TeamInterface.addTeamMembers

    Group owners and administrators invite users to join the group (addTeamMembers), and the invited users will receive a system notification of type teamInvite.

    The value of the from field of this system notification is the account of the inviter. The value of the to field is the group ID, the attach of this type of system notification has a field team whose value is the group to join. The invited users can accept or reject the invitation.

    • If a user accepts the invitation to join the group, all members of the group will receive a group notification of type acceptTeamInvite, the specific content of the notification message is as follows.
    • If a user rejects the invitation, the person who sent the invitation will receive a system notification of type rejectTeamInvite, the value of the from field is the account ID of the user who rejects the invitation, and the value of the to field is the group ID

    If a user accepts an invitation to join a group,

    1. All group members (except the sender) receive a group notification onmsg:
      • msg.type: 'notification'
      • msg.from: Inviter account
      • msg.to: Group ID
      • msg.attach.type: 'acceptTeamInvite'
      • msg.attach.team: Group information
      • msg.attach.members: List of members who accept the invitation
    2. All group members get notified by onupdatesessions
    3. All group members get notified by onAddTeamMembers
    4. The function call triggers onupdatesysmsg

    Associated function

    Parameters

    • _options: { from: string; idServer: string; teamId: string; done?: any }
      • from: string

        accountId of the requester

      • idServer: string

        idServer of the notification for invitation from an administrator.

      • teamId: string
      • done?:function

    Returns void

  • addCollect(_options: { custom?: string; data: string; type: number; uniqueId?: string; done?: any }): void
  • Add collection, and the content of the collections determined according to the business scenario. Collections are only visible to the current user.

    Parameters

    • _options: { custom?: string; data: string; type: number; uniqueId?: string; done?: any }
      • Optional custom?: string

        the bookmark extension field that can contain 1024 characters

      • data: string

        The specific data of the bookmark, the maximum number of characters is 20480

      • type: number

        Type, you can customize the mapping relationship, must be an integer

      • Optional uniqueId?: string

        Unique ID.

        Note: When the uniqueId is passed,the server checks whether there is a collection record before for uniqueId. If it does not exist, a new collection will be added, and if it exists, the collection will be updated.

      • done?:function

    Returns void

  • addFriend(_options: { account: string; ps?: string; done?: any }): void
  • addMsgPin(_options: { msg: NIMMsgPinInfo; pinCustom?: string; done?: any }): void
  • addQuickComment(_options: { apnsText?: string; body: number; custom?: string; msg: NIMMessage; needBadge?: boolean; needPush?: boolean; pushPayload?: NIMStrAnyObj; pushTitle?: string; done?: any }): void
  • Add a quick comment

    • Comments have only a few fields, can be deleted, and are not counted as unread
    • The clients of the sender and the commenter will trigger the NIMGetInstanceOptions.onQuickComment callback.

    Parameters

    • _options: { apnsText?: string; body: number; custom?: string; msg: NIMMessage; needBadge?: boolean; needPush?: boolean; pushPayload?: NIMStrAnyObj; pushTitle?: string; done?: any }
      • Optional apnsText?: string

        Custom text for push notifications

      • body: number

        Comment

        Note: Enter an integer, you can create custom mapping rules. For example, 1 for the like emoj, 2 for the clapping emoj.

      • Optional custom?: string

        Extension

      • msg: NIMMessage

        Message to be replied

      • Optional needBadge?: boolean

        Whether message count is required (badge at the app corner). The default value is false.

      • Optional needPush?: boolean

        whether a push notification is required. The default value is false..

      • Optional pushPayload?: NIMStrAnyObj

        Custom property of a push notification in JSON.

      • Optional pushTitle?: string

        Title for a push notification

      • done?:function
        • done(err: null | NIMCommonError | Error | NIMStrAnyObj, data: { comment: { body: number; custom?: string; from: string; time: number }; msg: { from: string; idServer: string; scene: "p2p" | "team" | "superTeam"; time: number; to: string } }): void
        • Parameters

          • err: null | NIMCommonError | Error | NIMStrAnyObj
          • data: { comment: { body: number; custom?: string; from: string; time: number }; msg: { from: string; idServer: string; scene: "p2p" | "team" | "superTeam"; time: number; to: string } }
            • comment: { body: number; custom?: string; from: string; time: number }

              Comment

              • body: number

                Quick comment

              • Optional custom?: string

                Extension

              • from: string

                ID of the account making the comment.

              • time: number

                time when the comment is posted.

            • msg: { from: string; idServer: string; scene: "p2p" | "team" | "superTeam"; time: number; to: string }

              Message, extract several fields in the NIMMessage structure, and idServer must exist.

              • from: string

                account of a sender

              • idServer: string

                The ID used by the server to distinguish messages, used to get message history and keywords for searching message history.

                Note: This field may not be available. For example, the message is filtered by anti-spam.

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

                Messaging scenario:

                • p2p: Private chat
                • team: group chat
                • superteam: supergroup chat
              • time: number

                Timestamp

              • to: string

                ID of a recipient, account ID or group ID

          Returns void

    Returns void

  • addStickTopSession(_options: { id: string; topCustom?: string; done: any }): void
  • addSuperTeamManagers(_options: { accounts: string[]; teamId: string; done?: any }): void
  • Add an administrator

    If administrators are added:

    1. All group members (except the sender) receive a group notification onmsg:
      • msg.type: 'notification'
      • msg.from: Operator that adds an administrator
      • msg.to: Group ID
      • msg.attach.type: 'addSuperTeamManagers'
      • msg.attach.accounts: List of accounts added as administrators
      • msg.attach.members: Detailed information about administrators
    2. All group members get notified by onupdatesessions
    3. All members get notified by onUpdateSuperTeamManagers

    Parameters

    Returns void

  • addSuperTeamMembers(_options: { accounts: string[]; custom?: string; ps?: string; teamId: string; done?: any }): void
  • Add group members

    • for inviteMode: 'noVerify':
    1. The invited user joins the supergroup without verification. All group members (except the sender) trigger onmsg:
      • msg.type: 'notification'
      • msg.from: Inviter account
      • msg.to: Group ID
      • msg.attach.type: 'addSuperTeamMembers'
      • msg.attach.team: Group information
      • msg.attach.members: List of invited gourp members
    2. All group members get notified by onupdatesessions
    3. All group members get notified by onAddSuperTeamMembers
    • for inviteMode: 'needVerify'
    1. Invited members get notified by onsysmsg of type 'superTeamInvite'。 The invited user can acceptSuperTeamInvite or rejectSuperTeamInvite the invitation.

    Parameters

    • _options: { accounts: string[]; custom?: string; ps?: string; teamId: string; done?: any }
      • accounts: string[]

        List of accounts that want to join the group

      • Optional custom?: string

        Additional fields, JSON string is recommended

      • Optional ps?: string

        Additional message, the length cannot be greater than 5000 characters, you can use serialized data in JSON string.

      • teamId: string
      • done?:function

    Returns void

  • addTeamManagers(_options: { accounts: string[]; teamId: string; done?: any }): void
  • Add an administrator

    If administrators are added:

    1. All group members (except the sender) trigger onmsg:
      • msg.type: 'notification'
      • msg.from: Operator that adds an administrator
      • msg.to: Group ID
      • msg.attach.type: 'addTeamManagers'
      • msg.attach.accounts: List of accounts added as administrators
      • msg.attach.members: Detailed information about administrators
    2. All group members get notified by onupdatesessions
    3. All members get notified by onUpdateTeamManagers

    Parameters

    Returns void

  • addTeamMembers(_options: { accounts: string[]; custom?: string; ps?: string; teamId: string; done?: any }): void
  • Add group members

    The basic group is deprecated. Use the advanced group:

    1. If new members are add and join the group, other group members will receive a notification and trigger onAddTeamMembers

    2. The invited group members will not receive the notification until members in the group send a message in the group and trigger the onupdatesessions callback.

    Advanced group:

    • for inviteMode: 'noVerify':
    1. All group members (except the sender) trigger onmsg:
      • msg.type: 'notification'
      • msg.from: Inviter account
      • msg.to: Group ID
      • msg.attach.type: 'addTeamMembers'
      • msg.attach.accounts: List of invited gourp members
      • msg.attach.members: List of invited gourp members
    2. All group members get notified by onupdatesessions
    3. All group members get notified by onAddTeamMembers
    • for inviteMode: 'needVerify'
    1. Invited members get notified by onsysmsg with type 'teamInvite'. Invited user can accept the invitation by calling acceptTeamInvite or reject the invitation by calling rejectTeamInvite.

    Parameters

    • _options: { accounts: string[]; custom?: string; ps?: string; teamId: string; done?: any }
      • accounts: string[]

        List of accounts that want to join the group

      • Optional custom?: string

        Additional fields, JSON string is recommended

      • Optional ps?: string

        Additional message, the length cannot be greater than 5000 characters, you can use serialized data in JSON string.

      • teamId: string
      • done?:function

    Returns void

  • addToBlacklist(_options: { account: string; done?: any }): void
  • Add to the blocklist The onblacklist callback is triggered during initialization and onsyncmarkinblacklist triggered during synchronization across devices.

    Example

    Parameters

    • _options: { account: string; done?: any }
      • account: string
      • done?:function
        • done(err: null | NIMCommonError | Error | NIMStrAnyObj, data: { account: string; isAdd: boolean; record: { account: string; updateTime: number } }): void
        • Parameters

          • err: null | NIMCommonError | Error | NIMStrAnyObj
          • data: { account: string; isAdd: boolean; record: { account: string; updateTime: number } }
            • account: string

              Target account ID

            • isAdd: boolean

              Whether the account is included in the blocklist or the list of muted members.

              true: Yes, false: No.

            • record: { account: string; updateTime: number }

              Details of the operation record

              • account: string

                Target account ID

              • updateTime: number

                Update timestamp

          Returns void

    Returns void

  • addToMutelist(_options: { account: string; done?: any }): void
  • Add to the list of muted members. The onmutelist callback is triggered during initialization and onsyncmarkinmutelist triggered during synchronization across devices.

    • Apply do-not-disturb by managing a list of muted users.
    • If the muted user send a message, the message will not be forwarded by push notifications.
    • On the UI layer, you can determine whether to render the number of unread messages in the conversation.

    Example

    Parameters

    • _options: { account: string; done?: any }
      • account: string
      • done?:function
        • done(err: null | NIMCommonError | Error | NIMStrAnyObj, data: { account: string; isAdd: boolean; record: { account: string; updateTime: number } }): void
        • Parameters

          • err: null | NIMCommonError | Error | NIMStrAnyObj
          • data: { account: string; isAdd: boolean; record: { account: string; updateTime: number } }
            • account: string

              Target account ID

            • isAdd: boolean

              Whether the account is included in the blocklist or the list of muted members.

              true: Yes, false: No.

            • record: { account: string; updateTime: number }

              Details of the operation record

              • account: string

                Target account ID

              • updateTime: number

                Update timestamp

          Returns void

    Returns void

  • applyFriend(_options: { account: string; ps?: string; done?: any }): void
  • applySuperTeam(_options: { ps?: string; teamId: string; done?: any }): void
  • A user requests to join a supergroup. SDK behaves differently depending on joinMode

    • For joinMode: 'noVerify':
    1. All group members (except the sender) trigger onmsg:
      • msg.type: 'notification'
      • msg.from: Account of the requester
      • msg.to: Group ID
      • msg.attach.type: 'passSuperTeamApply'
      • msg.attach.account: Account of the requester
      • msg.attach.members: List of accounts whose requests are approved
    2. All group members get notified by onupdatesessions
    3. All group members get notified by onAddSuperTeamMembers
    • For joinMode: 'needVerify'
    1. Administrators get notified by onsysmsg,其 type 为 'applySuperTeam'。 Administrators passSuperTeamApply or rejectSuperTeamApply the request.
    • For joinMode: 'rejectAll'
    1. Receive an error message that the requester failed to join the group.

    Parameters

    Returns void

  • applyTeam(_options: { ps?: string; teamId: string; done?: any }): void
  • Request to join a group. SDK behaves differently depending on joinMode

    • For joinMode: 'noVerify':
    1. All group members (except the sender) trigger onmsg:
      • msg.type: 'notification'
      • msg.from: Account of the requester
      • msg.to: Group ID
      • msg.attach.type: 'passTeamApply'
      • msg.attach.account: Account of the requester
      • msg.attach.members: List of accounts whose requests are approved
    2. All group members get notified by onupdatesessions
    3. All group members get notified by onAddTeamMembers
    • For joinMode: 'needVerify'
    1. Administrators get notified by onsysmsg of type 'applyTeam'. Administrators can passTeamApply or rejectTeamApply the request.
    • For joinMode: 'rejectAll'
    1. Receive an error message that the requester failed to join the group.

    Parameters

    Returns void

  • audioToMp3(_options: { url: string }): string
  • audioToText(_options: { url: string; done: any }): void
  • Audio to text Note that this feature is only available in NIM. Chat room has not yet implemented this feature.

    • Only supports the audio URL obtained by previewFile or sendFile, or the URL of the received audio message.

    Parameters

    Returns void

  • blurImage(_options: { radius: number; sigma: number; url: string; done?: any }): void
  • apply Gaussian blurring

    • Only support image URLs obtained by previewing files or sending file messages, or image URLs obtained after other image operations.

    Parameters

    • _options: { radius: number; sigma: number; url: string; done?: any }
      • radius: number

        Gaussian blurring radius

      • sigma: number

        Gaussian blur standard deviation, cannot be less than 0

      • url: string

        Original URL to the image stored in NOS

      • done?:function

    Returns void

  • clearServerHistoryMsgsWithSync(_options: { ext?: string; isDeleteRoam?: boolean; isSyncSelf?: boolean; scene: "p2p" | "team" | "superTeam"; to: string; done?: any }): void
  • If you delete the message history and message records for sync on the CommsEase server, the message history of the conversation in the local database will also be deleted, but the conversation in the database will be retained. You can delete the conversations in the local database by calling {@link NIMGetInstanceOptions.deleteLocalSession}.

    If isSyncSelf is set to true, the account logged in on multiple devices will trigger onClearServerHistoryMsgs

    Associated function

    Example

    Parameters

    • _options: { ext?: string; isDeleteRoam?: boolean; isSyncSelf?: boolean; scene: "p2p" | "team" | "superTeam"; to: string; done?: any }
      • Optional ext?: string

        Extension field

      • Optional isDeleteRoam?: boolean

        Whether to delete message history for sync. Default value: true

      • Optional isSyncSelf?: boolean

        Specify whether to sync messages across devices. The default value is false

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

        Messaging use case

      • to: string

        The user you talk with。 If it is a private message, pass the account of the peer. For group chats, pass the group ID.

      • done?:function

    Returns void

  • connect(): void
  • After logging out of IM using the disconnect method, you can call connect to log in again. After calling getInstance, a persistent connection will be established automatically without calling connect

    Associated function

    Example

    nim.disconnect({
    done: function() {
    nim.connect()
    }
    })

    Returns void

  • createTeam(_options: { accounts?: string[]; announcement?: string; antiSpamBusinessId?: string; avatar?: string; beInviteMode?: "noVerify" | "needVerify"; custom?: string; intro?: string; inviteMode?: "manager" | "all"; joinMode?: "noVerify" | "needVerify" | "rejectAll"; name: string; ps?: string; type: "normal" | "advanced"; updateCustomMode?: "manager" | "all"; updateTeamMode?: "manager" | "all"; done?: any }): void
  • Create an advanced group The basic group is deprecated. Use the advanced group.

    • The following is the verification method for joining an advanced group (joinMode). The default value is needVerify
    1. needVerify: Approval by administrators is required
    2. noVerify: Approval by administrators is not required
    3. rejectAll: All requests are rejected
    • The following is the verification method for invitations (beInviteMode) The default value is needVerify
    1. needVerify: Invitations must be accepted before invited users join the group
    2. noVerify: No consent is required from the invited users.
    • The following are permission options for invitations (inviteMode) The default value is manager
    1. manager: Only administrators or group owner can invite users
    2. all: All group members can invite users to join the group
    • Permissions for editing the group profile (updateTeamMode) The default value is manager
    1. manager: Only administrators can edit the properties of a group profile
    2. all: All group members can edit the properties of a group profile
    • Permissions for editing the custom properties of a group profile (updateTeamMode). The default value is manager
    1. manager: Only administrators can edit the properties of a group profile
    2. all: All group members can edit the properties of a group profile

    After the function call:

    • for the creator, onCreateTeam is triggered.
    • for beInviteMode: noVerify:
    1. Invited users get notified by onmsg, onupdatesessions, and NIMGetInstanceOptions.onAddTeamMembers
    2. Creator gets notified by onupdatesessions, and NIMGetInstanceOptions.onAddTeamMembers
    • for beInviteMode: needVerify:
    1. Invited users get notified by NIMGetInstanceOptions.onsysmsg of type teamInvite

    Parameters

    • _options: { accounts?: string[]; announcement?: string; antiSpamBusinessId?: string; avatar?: string; beInviteMode?: "noVerify" | "needVerify"; custom?: string; intro?: string; inviteMode?: "manager" | "all"; joinMode?: "noVerify" | "needVerify" | "rejectAll"; name: string; ps?: string; type: "normal" | "advanced"; updateCustomMode?: "manager" | "all"; updateTeamMode?: "manager" | "all"; done?: any }
      • Optional accounts?: string[]

        List of accounts to be invited

      • Optional announcement?: string

        Group announcement

      • Optional antiSpamBusinessId?: string

        Business ID for moderation configured in the CommsEase console.

      • Optional avatar?: string

        Group avatar

      • Optional beInviteMode?: "noVerify" | "needVerify"

        Verification method for invitations

      • Optional custom?: string

        Extension field

      • Optional intro?: string

        Group introduction

      • Optional inviteMode?: "manager" | "all"

        Invitation mode

      • Optional joinMode?: "noVerify" | "needVerify" | "rejectAll"

        Join method

      • name: string

        Group name

      • Optional ps?: string

        Additional message

      • type: "normal" | "advanced"

        Group type

      • Optional updateCustomMode?: "manager" | "all"

        Permissions for editing custom fields of a group profile

      • Optional updateTeamMode?: "manager" | "all"

        Permissions for editing the group profile

      • done?:function
        • Parameters

          • err: null | NIMCommonError | Error | NIMStrAnyObj
          • data: { accounts?: string[]; antispamTag?: { antiSpamBusinessId?: string }; owner: NIMTeamMember; ps?: string; team: NIMTeam }
            • Optional accounts?: string[]

              List of accounts to be invited

            • Optional antispamTag?: { antiSpamBusinessId?: string }

              Moderation tag

              • Optional antiSpamBusinessId?: string
            • owner: NIMTeamMember

              Owner information

            • Optional ps?: string

              Additional message

            • team: NIMTeam

              Group

          Returns void

    Returns void

  • cropImage(_options: { height: number; url: string; width: number; x: number; y: number; done?: any }): void
  • Crop an image

    • Only support image URLs obtained by previewing files or sending file messages, or image URLs obtained after other image operations.
    • Capture an image with size (width*height) from coordinates (x, y). The value of (0, 0) represents the upper left corner
    • The value of width/height cannot be less than 0. If width/height is greater than the original width/height of the image, it will be replaced by the original width/height of the image.

    Parameters

    • _options: { height: number; url: string; width: number; x: number; y: number; done?: any }
      • height: number

        Height

      • url: string

        Original URL to the image stored in NOS

      • width: number

        Width

      • x: number

        X coordinate, must be an integer

      • y: number

        Y coordinate, must be an integer

      • done?:function

    Returns void

  • deleteAllLocalMsgs(_options: { done?: any }): void
  • Delete all local messages. This method will clear all conversations in the database at the same time.

    Note: If the operating environment does not support the database, or the database is not running, the execution is successful, but no valid data will be returned or operated.

    Parameters

    Returns void

  • deleteAllLocalSysMsgs(_options: { done?: any }): void
  • deleteCollects(_options: { collectList: NIMCollect[]; done?: any }): void
  • deleteFriend(_options: { account: string; delAlias?: boolean; done?: any }): void
  • deleteLocalMsg(_options: { msg: NIMMessage; done?: any }): void
  • Description

    Delete a local message.

    • If the operating environment does not support the database, or the database is not running, the execution is successful, but no valid data will be returned.
    • If the last message of the conversation is deleted, the lastMsg property of the conversation will automatically change to the previous message, and the onupdatesessions callback will be triggered.
    • If the message does not exist, the method call will be evaluated as successful

    Parameters

    Returns void

  • deleteLocalMsgs(_options: { end?: number; sessionId: string; start?: number; updateSession?: boolean; done?: any }): void
  • Delete local messages based on conversation ID, start time and end time

    • If the operating environment does not support the database, or the database is not running, the execution is successful, but no valid data will be returned.
    • The end time must be greater than start time
    • If no start time and end time are specified, delete all local messages of a conversation by calling deleteLocalMsgsBySession

    Example

    Parameters

    • _options: { end?: number; sessionId: string; start?: number; updateSession?: boolean; done?: any }
      • Optional end?: number

        Timestamp of the end time for a search

      • sessionId: string

        session.id

      • Optional start?: number

        Timestamp of the start time for a search

      • Optional updateSession?: boolean

        Whether the conversation is synced. The default value is true

      • done?:function

    Returns void

  • deleteLocalMsgsBySession(_options: { delLastMsg?: boolean; isTag?: boolean; scene: "p2p" | "team" | "superTeam"; to: string; done?: any }): void
  • Delete all local messages in a specific conversation

    Note: If the operating environment does not support the database, or the database is not running, the execution is successful, but no valid data will be returned or operated.

    Parameters

    • _options: { delLastMsg?: boolean; isTag?: boolean; scene: "p2p" | "team" | "superTeam"; to: string; done?: any }
      • Optional delLastMsg?: boolean

        Whether session.lastMsg will also be deleted. The default value is false

      • Optional isTag?: boolean

        Whether the message is deleted by tag. The default value is false

        Note: If it is true, the message is deleted physically, and the localCustom local custom extension field inserted for this message cannot be retained. If the value is false, the message is deleted by logic.

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

        Messaging use case

      • to: string

        The user you talk with。 If it is a private message, pass the account of the peer. For group chats, pass the group ID.

      • done?:function

    Returns void

  • deleteLocalMsgsByTime(_options: { end?: number; start?: number; deletedone?: any; done?: any }): Promise<void>
  • Delete the messages of the specified time range at a time.

    Note: If the operating environment does not support the database, or the database is not running, the execution is successful, but no valid data will be returned or operated.

    Parameters

    • _options: { end?: number; start?: number; deletedone?: any; done?: any }
      • Optional end?: number

        Timestamp of the end time. Use Infinity by default if unspecified.

      • Optional start?: number

        Timestamp of start time in milliseconds, default value: 0

      • deletedone?:function
        • deletedone(data: { deletedMsgCount: number }): void
        • Callback invoked when a message is deleted. You can search for messages after this callback.

          Parameters

          • data: { deletedMsgCount: number }
            • deletedMsgCount: number

          Returns void

      • done?:function
        • done(err: null | NIMCommonError | Error, data: null | { deletedMsgCount: number; sessionUpdateCount: number }): void
        • Parameters

          • err: null | NIMCommonError | Error
          • data: null | { deletedMsgCount: number; sessionUpdateCount: number }

          Returns void

    Returns Promise<void>

  • deleteLocalSession(_options: { id: string; isDeleteRoaming?: boolean; isLogic?: boolean; done?: any }): void
  • deleteLocalSysMsg(_options: { idServer: string | string[]; done?: any }): void
  • deleteLocalTeam(_options: { teamId: string | string[]; done?: any }): void
  • deprecated

    Parameters

    • _options: { teamId: string | string[]; done?: any }
      • teamId: string | string[]

        Pass teamId array.

        Note: To be compatible with the legacy interfaces, only string data is allowed. An array is recommended.

      • done?:function

    Returns void

  • deleteMsg(_options: { apnsText?: string; attach?: string; env?: string; msg: NIMMessage; ps?: string; pushPayload?: string; done?: any }): void
  • deprecated,

    use recallMsg

    Parameters

    • _options: { apnsText?: string; attach?: string; env?: string; msg: NIMMessage; ps?: string; pushPayload?: string; done?: any }
      • Optional apnsText?: string

        Custom text for push notifications

      • Optional attach?: string

        Additional information, JSON string is recommended

      • Optional env?: string

        Environment for messaging webhooks

      • msg: NIMMessage

        message to be unsent

      • Optional ps?: string

        Additional message

      • Optional pushPayload?: string

        Custom properties for push notifications, must be JSON string.

      • done?:function

    Returns void

  • deleteMsgSelf(_options: { custom?: string; msg: NIMMessage; done?: any }): void
  • Delete a message only for the current user. After deletion, the message remains visible to other users. If an account is logged in on multiple devices, this function will trigger the callback of onDeleteMsgSelf on other devices.

    Parameters

    Returns void

  • deleteMsgSelfBatch(_options: { custom?: string; msgs: NIMMessage[]; done?: any }): void
  • deleteNosAccessToken(_options: { ext?: string; url: string; userAgent?: string; done: any }): void
  • deprecated

    Get the authentication token of the shortened URL to get the file. Deprecated after v8.10.0. The new interface getFileAuthToken does not delete the token.

    Parameters

    • _options: { ext?: string; url: string; userAgent?: string; done: any }
      • Optional ext?: string
      • url: string

        URL to get the file

      • Optional userAgent?: string
      • done:function
        • Parameters

          Returns void

    Returns void

  • deleteQuickComment(_options: { apnsText?: string; body: number; custom?: string; msg: NIMMessage; needBadge?: boolean; needPush?: boolean; pushPayload?: NIMStrAnyObj; pushTitle?: string; done?: any }): void
  • Delete a quick comment

    Parameters

    • _options: { apnsText?: string; body: number; custom?: string; msg: NIMMessage; needBadge?: boolean; needPush?: boolean; pushPayload?: NIMStrAnyObj; pushTitle?: string; done?: any }
      • Optional apnsText?: string

        Custom text for push notifications

      • body: number

        Comment

        Note: Enter an integer, you can create custom mapping rules. For example, 1 for the like emoj, 2 for the clapping emoj.

      • Optional custom?: string

        Extension

      • msg: NIMMessage

        Message to be replied

      • Optional needBadge?: boolean

        Whether message count is required (badge at the app corner). The default value is false.

      • Optional needPush?: boolean

        whether a push notification is required. The default value is false..

      • Optional pushPayload?: NIMStrAnyObj

        Custom property of a push notification in JSON.

      • Optional pushTitle?: string

        Title for a push notification

      • done?:function
        • done(err: null | NIMCommonError | Error | NIMStrAnyObj, data: { comment: { body: number; custom?: string; from: string; time: number }; msg: { from: string; idServer: string; scene: "p2p" | "team" | "superTeam"; time: number; to: string } }): void
        • Parameters

          • err: null | NIMCommonError | Error | NIMStrAnyObj
          • data: { comment: { body: number; custom?: string; from: string; time: number }; msg: { from: string; idServer: string; scene: "p2p" | "team" | "superTeam"; time: number; to: string } }
            • comment: { body: number; custom?: string; from: string; time: number }

              Comment

              • body: number

                Quick comment

              • Optional custom?: string

                Extension

              • from: string

                ID of the account making the comment.

              • time: number

                time when the comment is posted.

            • msg: { from: string; idServer: string; scene: "p2p" | "team" | "superTeam"; time: number; to: string }

              Message, extract several fields in the NIMMessage structure, and idServer must exist.

              • from: string

                account of a sender

              • idServer: string

                The ID used by the server to distinguish messages, used to get message history and keywords for searching message history.

                Note: This field may not be available. For example, the message is filtered by anti-spam.

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

                Messaging scenario:

                • p2p: Private chat
                • team: group chat
                • superteam: supergroup chat
              • time: number

                Timestamp

              • to: string

                ID of a recipient, account ID or group ID

          Returns void

    Returns void

  • deleteServerSessions(_options: { sessions: { scene: "p2p" | "team" | "superTeam"; to: string }[]; done: any }): void
  • deleteSession(_options: { scene: "p2p" | "team" | "superTeam"; to: string; done?: any }): void
  • deleteSessions(_options: { sessions: NIMSession[]; done?: any }): void
  • deleteSessionsWithMoreRoaming(_options: { id: string; done?: any }): void
  • deleteStickTopSession(_options: { id: string; done: any }): void
  • destroy(_options: { done?: any }): void
  • Disconnect from the server and destroy the IM instance If the instance is destroyed, you cannot call connect to reconnect to the chat room.

    Note that in NIM SDK v9.9.0 and earlier versions, the ondisconnect callback function will be triggered directly after calling destroy, but the persistent connection is not actually closed. Only when the done callback is triggered, can the persistent connection be truly closed. To avoid device exclusion during reconnection, you must set reconnection and other operations in the done callback for the destroy method.

    Associated function

    Parameters

    Returns void

  • disconnect(_options: { done?: any }): void
  • Disconnect from the server, but do not destroy the IM instance After logging in by calling connect, the data will be incrementally synchronized based on the instance status

    Note that in NIM SDK v9.9.0 and earlier versions, the ondisconnect callback function will be triggered directly after calling destroy, but the persistent connection is not actually closed. Only when the done callback is triggered, can the persistent connection be truly closed. To avoid device exclusion during reconnection, you must set reconnection and other operations in the done callback for the destroy method.

    Associated function

    Notes

    Parameters

    Returns void

  • dismissTeam(_options: { teamId: string; done?: any }): void
  • Delete a group. Only the owner can delete a group.

    1. All group members (except the sender) trigger onmsg:
      • msg.type: 'notification'
      • msg.from: Operator account
      • msg.to: Group ID
      • msg.attach.type: 'dismissTeam'
    2. All group members get notified by onupdatesessions 3.All group members get notified by onDismissTeam

    Parameters

    Returns void

  • Return an array listing the events for which the emitter has registered listeners.

    Returns keyof NIMSignalingEventInterface[]

  • filterClientAntispam(_options: { content: string }): { code: number; content: string; errmsg: string; result: string; type: number }
  • Check client-side moderation For information about client-side moderation, see Content moderation

    Note: Before calling this interface, you must get the keywords for moderation by calling getClientAntispamLexicon. Otherwise, an error 404 no keywords for moderation will appear

    Example

    Parameters

    • _options: { content: string }
      • content: string

        Text for moderation

    Returns { code: number; content: string; errmsg: string; result: string; type: number }

    • code: number

      Status of a request

    • content: string

      Text for moderation

    • errmsg: string

      Suggestion for hit content

    • result: string

      Verified for pass

    • type: number

      Result types

      0: pass 1: filtered and released 2: rejected 3: hit by client-side moderation rules, handled by the server, messages for delivery contain the clientAntiSpam field.

  • forwardMsg(_options: { msg: NIMMessage; scene: "p2p" | "team" | "superTeam"; to: string; done?: any }): NIMMessage
  • getAllSuperTeamMembers(_options: { teamId: string; done?: any }): void
  • getChatroomAddress(_options: { chatroomId: string; done: any }): void
  • Get the connection address of the chat room and return a list of available connection addresses

    deprecated

    server interface is recommended to get the connection address for chat rooms

    Parameters

    • _options: { chatroomId: string; done: any }
      • chatroomId: string

        Chat room ID

      • done:function
        • done(err: null | NIMCommonError | Error | NIMStrAnyObj, data: { address: string[]; chatroomId: string; ipType: number; isWeixinApp: boolean; type: number }): void
        • Parameters

          • err: null | NIMCommonError | Error | NIMStrAnyObj
          • data: { address: string[]; chatroomId: string; ipType: number; isWeixinApp: boolean; type: number }
            • address: string[]

              List of addresses for chat rooms

            • chatroomId: string

              Chat room ID

            • ipType: number

              0: IPv4 addresses, 1: IPv6 addresses, 2: unlimited.

              Default value: 0.

            • isWeixinApp: boolean

              Whether an address for the WeChat environment is provided.

            • type: number

          Returns void

    Returns void

  • getClientAntispamLexicon(_options: { done: any }): void
  • Get the keyword filters for moderation. You can get the keywords for moderation using this API and store the keywords in the memory.

    For more information, visit Content moderation

    Use case

    Parameters

    • _options: { done: any }
      • done:function
        • done(err: null | NIMCommonError | Error | NIMStrAnyObj, data: { clientAntispam: { md5: string; nosurl: string; thesaurus: string; version: string } }): void
        • Parameters

          • err: null | NIMCommonError | Error | NIMStrAnyObj
          • data: { clientAntispam: { md5: string; nosurl: string; thesaurus: string; version: string } }
            • clientAntispam: { md5: string; nosurl: string; thesaurus: string; version: string }
              • md5: string

                MD5 value of the keywords file for moderation

              • nosurl: string

                The download URL of a keywords file for moderation

              • thesaurus: string

                Keywords content parsed as a JSON object for moderation

              • version: string

                Version of Keywords for moderation

          Returns void

    Returns void

  • getCollects(_options: { beginTime?: number; endTime?: number; lastId?: string; limit?: number; reverse?: boolean; type?: number; done?: any }): void
  • Query collections

    Parameters

    • _options: { beginTime?: number; endTime?: number; lastId?: string; limit?: number; reverse?: boolean; type?: number; done?: any }
      • Optional beginTime?: number

        Timestamp of start time in milliseconds, default value: 0

      • Optional endTime?: number

        Timestamp of the end time in milliseconds. the default value is the current server time

      • Optional lastId?: string

        The ID of the last collection in the last query

        Note: It is recommended to fill out from the second page, so that the server can distinguish two records with the same timestamp.

      • Optional limit?: number

        The upper limit of messages per query. 100 messages by default

      • Optional reverse?: boolean

        Sorting order. The default value is false

        If true, query in ascending order by timestamp, and limit number of records from beginTime to endTime

        If false, query in descending order by timestamp, and limit number records from endTime to beginTime

      • Optional type?: number

        Type, you can customize the mapping relationship, must be an integer. All types of messages are queried by default.

      • done?:function

    Returns void

  • getFriends(_options: { updateTime?: number; done?: any }): void
  • If you set syncFriends to false when initializing the SDK, the onfriends callback will not be triggered. In this case, this interface can obtain the friend list

    Note: Since the upper limit of the number of friends after v8.9.0 becomes 10,000, the remote protocol does not allow the SDK to send 10,000 friends in one go. There are two ways to get all friends at a time:

    1. If a database is used, this interface will return all valid friend records in the database with updateTime > options.updateTime

    2. If a database is not used, this interface with a timestamp argument will get 3000 records of updateTime > options.timetag from the server. Please handle the pagination logic on your own.

    Parameters

    Returns void

  • getHistoryMsgs(_options: { asc?: boolean; beginTime?: number; endTime?: number; lastMsgId?: string; limit?: number; msgTypes?: ("custom" | "text" | "image" | "audio" | "video" | "geo" | "notification" | "file" | "tip" | "robot" | "g2")[]; reverse?: boolean; scene: "p2p" | "team" | "superTeam"; to: string; done?: any }): void
  • Get the message history stored on the CommsEase server. The time range is defined by the parameters beginTime and endTime.

    • If reverse is set to false, the endTime of the subsequent query corresponds to the time field of the last message of the previous query.
    • If reverse is set to true, the beginTime of the subsequent query corresponds to the time field of the last message of the previous query
    • If you want to search message history, see MessageLogInterface.msgFtsInServer

    Use cases

    This API call is triggered when users opens a conversation and render the message list or "pulls down to view more messages".

    Notes

    • This API gets the message history on the CommsEase server, but does not insert it into the local database.
    • This API returns the list of returned messages using the options.done callback.
    • In the initialization, if this function is called before the synchronization is completed, the read status of the conversation may be inaccurate

    Example

    Parameters

    • _options: { asc?: boolean; beginTime?: number; endTime?: number; lastMsgId?: string; limit?: number; msgTypes?: ("custom" | "text" | "image" | "audio" | "video" | "geo" | "notification" | "file" | "tip" | "robot" | "g2")[]; reverse?: boolean; scene: "p2p" | "team" | "superTeam"; to: string; done?: any }
      • Optional asc?: boolean

        Sorting order. The default value is false

        false means that the returned messages are sorted in descending order by time;

        true means the returned messages are sorted in ascending order by time;

      • Optional beginTime?: number

        Timestamp of start time in milliseconds, default value: 0

      • Optional endTime?: number

        Timestamp of the end time in milliseconds. the default value: 0

      • Optional lastMsgId?: string

        The idServer of the last message in the last query. No value for the first query.

      • Optional limit?: number

        limit on the number of queries per page, the default value is 100

      • Optional msgTypes?: ("custom" | "text" | "image" | "audio" | "video" | "geo" | "notification" | "file" | "tip" | "robot" | "g2")[]

        Specified message type. All message types if unspecified

      • Optional reverse?: boolean

        Query sequence. The default value is false, indicating the result is displayed in descending order.

        false Search limit number of history messages forward from endTime

        true Search limit number of history messages backward from beginTime

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

        Messaging use case

      • to: string

        The user you talk with。 If it is a private message, pass the account of the peer. For group chats, pass the group ID.

      • done?:function

    Returns void

  • getLocalMsgs(_options: { desc?: boolean; end?: number; keyword?: string; limit?: number; sessionId?: string; start?: number; subTypes?: number[]; types?: ("custom" | "text" | "image" | "audio" | "video" | "geo" | "notification" | "file" | "tip" | "robot" | "g2")[]; done?: any }): void
  • Description

    Retrieve message history from the local database.

    Use cases

    This API call is triggered when users opens a conversation and render the message list or "pulls down to view more messages".

    Notes

    If the runtime environment does not support the database, or the database is not running, the execution is successful, but no valid data be returned.

    Parameters

    • _options: { desc?: boolean; end?: number; keyword?: string; limit?: number; sessionId?: string; start?: number; subTypes?: number[]; types?: ("custom" | "text" | "image" | "audio" | "video" | "geo" | "notification" | "file" | "tip" | "robot" | "g2")[]; done?: any }
      • Optional desc?: boolean

        true means search from end, false means search from begin

      • Optional end?: number

        Timestamp of the end time for a search

      • Optional keyword?: string

        [for indexedDB only] If parameters are provided, query messages matching this keyword

        Note: The query with this parameter is in the forward index mode, and the query will be quite slow when the amount of data is large. If you need to support full-text search (inverted index structure), see fts interfaces

      • Optional limit?: number

        Pagination limit

      • Optional sessionId?: string

        If specified, search messages in this conversation

      • Optional start?: number

        Timestamp of the start time for a search

      • Optional subTypes?: number[]

        [indexedDB dedicated] If this parameter is provided, query these subtypes of messages

      • Optional types?: ("custom" | "text" | "image" | "audio" | "video" | "geo" | "notification" | "file" | "tip" | "robot" | "g2")[]

        [indexedDB specific] If this parameter is provided, query this type of message

      • done?:function

    Returns void

  • getLocalMsgsByIdClients(_options: { idClients: string[]; done?: any }): void
  • getLocalSession(_options: { sessionId: string; done: any }): void
  • getLocalSessions(_options: { lastSessionId?: string; limit?: number; reverse?: boolean; done: any }): void
  • Query the list of conversations in the local database.

    • If db is not enabled, this SDK returns a list of sessions maintained in the memory. While it is possible to return the list of conversations, it is not recommended. You must maintain conversation data in your app. For more information, see the sample code

    Note: The conversation list is sorted in descending order by updateTime, that is, the most recently conversations are displayed at the top.

    Example

    Parameters

    • _options: { lastSessionId?: string; limit?: number; reverse?: boolean; done: any }
      • Optional lastSessionId?: string

        The ID of the last conversation on the previous page, you can leave it blank for the first query.

      • Optional limit?: number

        limit on the number of queries per page, the default value is 100

      • Optional reverse?: boolean

        Query order. The default value is false, indicating the result is displayed in descending order.

        value: false. Indicates to search for local conversations starting from the most recent conversations.

        true, search for local conversations from the first conversation.

      • done:function

    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
  • Get system notifications from the local database

    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

        The idServer of the last system notification in the last query.

      • Optional limit?: number

        limit on the number of queries on one page, the default value is 100

      • Optional read?: boolean

        Whether the notification is read

      • Optional reverse?: boolean

        Query sequence

        Default value: false. Indicates to search for local system notifications starting from the most recent system notifications. If it is true, search for local system notifications from the first system notification

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

        Type

      • done?:function

    Returns void

  • getLocalTeamMembers(_options: { accounts: string[]; teamId: string; done?: any }): void
  • getLocalTeams(_options: { teamIds: string[]; done: any }): void
  • getMsgPins(_options: { id: string; done?: any }): void
  • getMsgsByIdServer(_options: { reqMsgs: { from: string; idServer: string; scene: "p2p" | "team" | "superTeam"; time: number; to: string }[] }): void
  • Query message history by message ID and other information, exclusive to thread chat

    Parameters

    • _options: { reqMsgs: { from: string; idServer: string; scene: "p2p" | "team" | "superTeam"; time: number; to: string }[] }
      • reqMsgs: { from: string; idServer: string; scene: "p2p" | "team" | "superTeam"; time: number; to: string }[]

        query parameters, several fields in the NIMMessage structure, and idServer is required.

    Returns void

  • getMutedSuperTeamMembers(_options: { joinTime?: number; limit?: number; reverse?: boolean; teamId: string; done?: any }): void
  • getMutedTeamMembers(_options: { teamId: string; done?: any }): void
  • getNosAccessToken(_options: { ext?: string; url: string; userAgent?: string; done: any }): void
  • deprecated

    Get the authentication token of the shortened URL to get the file. Deprecated after v8.10.0, use {@link CloudStorageInterface.getFileAuthToken}

    Parameters

    • _options: { ext?: string; url: string; userAgent?: string; done: any }
      • Optional ext?: string
      • url: string

        URL to get the file

      • Optional userAgent?: string
      • done:function
        • Parameters

          Returns void

    Returns void

  • getNosOriginUrl(_options: { safeShortUrl: string; done: any }): void
  • getQuickComments(_options: { msgs: NIMMessage[]; done?: any }): void
  • Get multiple quick comments at a time.

    Parameters

    • _options: { msgs: NIMMessage[]; done?: any }
      • msgs: NIMMessage[]

        Message to be replied

      • done?:function
        • done(err: null | NIMCommonError | Error | NIMStrAnyObj, data: { commentTimetag: number; comments: { body: number; custom?: string; from: string; time: number }[]; idClient: string; idServer: string }): void
        • Parameters

          • err: null | NIMCommonError | Error | NIMStrAnyObj
          • data: { commentTimetag: number; comments: { body: number; custom?: string; from: string; time: number }[]; idClient: string; idServer: string }
            • commentTimetag: number

              The recent update time of a quick comment.

            • comments: { body: number; custom?: string; from: string; time: number }[]
            • idClient: string

              idClient of a message commented

            • idServer: string

              idServer of a message commented

          Returns void

    Returns void

  • getRelations(_options: { done?: any }): void
  • Get the blocklist and list of muted members. If you set syncRelations to false when initializing the SDK, you cannot get notified by the onblacklist and onmutelist callbacks. In this case, you can call this interface to get the blocklist and the list of muted members.

    Parameters

    • _options: { done?: any }
      • done?:function
        • done(err: null | NIMCommonError | Error | NIMStrAnyObj, data: { blacklist: { account: string; createTime: number; isBlack?: boolean; isMuted?: boolean; updateTime: number }[]; mutelist: { account: string; createTime: number; isBlack?: boolean; isMuted?: boolean; updateTime: number }[] }): void
        • Parameters

          • err: null | NIMCommonError | Error | NIMStrAnyObj
          • data: { blacklist: { account: string; createTime: number; isBlack?: boolean; isMuted?: boolean; updateTime: number }[]; mutelist: { account: string; createTime: number; isBlack?: boolean; isMuted?: boolean; updateTime: number }[] }
            • blacklist: { account: string; createTime: number; isBlack?: boolean; isMuted?: boolean; updateTime: number }[]
              • account: IM account
              • isMuted: * Check if the user is muted.
              • isBlack: Check if a user is included in the blocklist.
            • mutelist: { account: string; createTime: number; isBlack?: boolean; isMuted?: boolean; updateTime: number }[]
              • account: IM account
              • isMuted: * Check if the user is muted.
              • isBlack: Check if a user is included in the blocklist.

          Returns void

    Returns void

  • getServerSession(_options: { scene: "p2p" | "team" | "superTeam"; to: string; done: any }): void
  • getServerSessions(_options: { limit?: number; maxTimestamp?: number; minTimestamp?: number; needLastMsg?: boolean; done: any }): void
  • Get the server sessions

    Parameters

    • _options: { limit?: number; maxTimestamp?: number; minTimestamp?: number; needLastMsg?: boolean; done: any }
      • Optional limit?: number

        Pagination size, default value: 100.

      • Optional maxTimestamp?: number

        Maximum timestamp Form a time period with minTimestamp as a query condition.

        The current timestamp by default

      • Optional minTimestamp?: number

        Minimum timestamp Form a time period with maxTimestamp as a query condition.

        Default value 0 means unlimited.

      • Optional needLastMsg?: boolean

        Specify whether last message is needed.. Default value: true

      • done:function

    Returns void

  • getServerTime(_options: { done: any }): void
  • getSessionsWithMoreRoaming(_options: { id: string; done?: any }): void
  • getStickTopSessions(_options: { done: any }): void
  • getSuperTeam(_options: { teamId: string; done: any }): void
  • getSuperTeamMembersByAccounts(_options: { accounts: string[]; teamId: string; done?: any }): void
  • getSuperTeamMembersByJoinTime(_options: { joinTime?: number; limit?: number; reverse?: boolean; teamId: string; done?: any }): void
  • Retrieve the list of members by the join time.

    Parameters

    • _options: { joinTime?: number; limit?: number; reverse?: boolean; teamId: string; done?: any }
      • Optional joinTime?: number

        Whether to mute the group Time when a member joined the group

        Note: If this argument is used, get members who joined after this time, if not, there is no limit

      • Optional limit?: number

        Pagination limit, default value: 100, return 100 pieces of data

      • Optional reverse?: boolean

        Query order. The default value is false

        false means to query the members joined after joinTime

        true means to query members joined before joinTime

      • teamId: string
      • done?:function

    Returns void

  • getSuperTeams(_options: { done?: any }): void
  • Get the list of supergroups If you set syncSuperTeams to false when initializing the SDK, the data returned by the onSuperTeams callback will not be received. This Interface can get the list of supergroups.

    Note: If there is no local database, the SDK will get the list of supergroups from the server.

    Parameters

    Returns void

  • getTeam(_options: { sync?: boolean; teamId: string; done?: any }): void
  • Get a group

    Note: If the local database service is unavailable or the group can not be retrieved from the local datab ase, the SDK will get the group from the CommsEase server.

    Example

    Parameters

    • _options: { sync?: boolean; teamId: string; done?: any }

    Returns void

  • getTeamMemberByTeamIdAndAccount(_options: { account: string; teamId: string; done?: any }): void
  • getTeamMemberInvitorAccid(_options: { accounts: string[]; teamId: string; done?: any }): void
  • Get the ID of the account that invited the group member.

    Parameters

    • _options: { accounts: string[]; teamId: string; done?: any }
      • accounts: string[]

        A list of member account IDs to be queried.

        Note: The done callback fires every 200 calls.

      • teamId: string
      • done?:function
        • Parameters

          • err: null | NIMCommonError | Error | NIMStrAnyObj
          • data: {}
            • [key: string]: string

              The key is the account ID, value is the account ID of the inviter

          Returns void

    Returns void

  • getTeamMembers(_options: { teamId: string; done?: any }): void
  • getTeamMsgReadAccounts(_options: { teamMsgReceipt: { idClient?: string; idServer: string; teamId: string }; done?: any }): void
  • getTeamMsgReads(_options: { teamMsgReceipts: { idClient?: string; idServer: string; teamId: string }[]; done?: any }): void
  • Query the read and unread count of group messages.

    • If you configure the needMsgReceipt field for a group message when the group message is sent, the recipient can send a read receipt for the message.
    • The second parameter of the done callback is the sent parameter for verification, and the third parameter is the actual result.
    • When the database is supported and idClient exists:
    • After the query is completed, the corresponding message in the database will have read and unread properties, corresponding to the number of read and unread messages.
    • After the unread count of a message becomes 0, the number of read and unread messages will not change. Therefore, it is recommended to filter out the messages whose unread is 0 before calling this interface to reduce unnecessary resources consumption.

    Example

    Parameters

    • _options: { teamMsgReceipts: { idClient?: string; idServer: string; teamId: string }[]; done?: any }
      • teamMsgReceipts: { idClient?: string; idServer: string; teamId: string }[]

        List of group messages to be queried

      • done?:function
        • Note that the actual return data of this callback is in the third parameter

          Parameters

          Returns void

    Returns void

  • getTeams(_options: { done?: any }): void
  • Get groups

    • If you set syncSuperTeams to false when initializing the SDK, the data returned by the onSuperTeams callback will not be received, and this Interface can get the list of groups.

    Note: If there is no local database, the SDK will get the list of groups from the server.

    Parameters

    Returns void

  • getTeamsById(_options: { teamIds: string[]; done?: any }): void
  • Get groups by group IDs

    • You can obtain the information about several groups by calling this interface.

    Note: v8.2.0 support

    Parameters

    • _options: { teamIds: string[]; done?: any }

    Returns void

  • getThreadMsgs(_options: { beginTime?: number; endTime?: number; lastMsgId?: string; limit?: number; reverse?: boolean; scene: "p2p" | "team" | "superTeam"; threadMsgFromAccount: string; threadMsgIdServer: string; threadMsgTime: number; threadMsgToAccount: string; done?: any }): void
  • Get the list of messages in a thread.

    Parameters

    • _options: { beginTime?: number; endTime?: number; lastMsgId?: string; limit?: number; reverse?: boolean; scene: "p2p" | "team" | "superTeam"; threadMsgFromAccount: string; threadMsgIdServer: string; threadMsgTime: number; threadMsgToAccount: string; done?: any }
      • Optional beginTime?: number

        Start time in milliseconds. the default value: 0

      • Optional endTime?: number

        Timestamp of the end time in milliseconds, the default value is the current time of the server

      • Optional lastMsgId?: string

        The idServer of the last message in the last query. No value for the first query.

      • Optional limit?: number

        The upper limit of messages per query. 100 messages by default

      • Optional reverse?: boolean

        The default false means to search for message history forward from endTime, and true means to search for message history backward from beginTime

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

        Scenario

      • threadMsgFromAccount: string

        Sender account of a message in the thread

      • threadMsgIdServer: string

        ServerID of the root message in a thread.

      • threadMsgTime: number

        Time of the root message in a thread

      • threadMsgToAccount: string

        Recipient of a thread message

      • done?:function

    Returns void

  • getUser(_options: { account: string; sync?: boolean; done?: any }): void
  • getUsers(_options: { accounts: string[]; sync?: boolean; done?: any }): void
  • Get user profiles. Up to 150 profiles can be retrieved at a time.

    Parameters

    • _options: { accounts: string[]; sync?: boolean; done?: any }
      • accounts: string[]

        List of account IDs

      • Optional sync?: boolean

        Whether to get the account from the server. The default value is false

        Get it from the server if it is true, and get it from the information cached in the local database if it is false.

      • done?:function

    Returns void

  • insertLocalSession(_options: { scene: "p2p" | "team" | "superTeam"; to: string; done?: any }): void
  • Insert a conversation into the local database indexdb

    • If the database is not enabled, a session will be inserted in the memory. It is not recommended to use this function without db. You must maintain conversation data in the memory data.

    • If the conversation already exists, an error will be returned

    • If there is a local history message for this conversation, the lastMsg of the conversation will be updated to the last message.

    • The onupdatesysmsgunread callback is triggered after you insert this conversation.

    Parameters

    Returns void

  • interlaceImage(_options: { url: string; done?: any }): void
  • interlace image

    • Only support image URLs obtained by previewing files or sending file messages, or image URLs obtained after other image operations.
    • When the network condition is poor, interlaced images appears blurry or with lower resolution and then gradually becomes clearer.

    Parameters

    • _options: { url: string; done?: any }

    Returns void

  • isMsgRemoteRead(_options: { msg: NIMMessage }): boolean
  • deprecated.

    This interface is used to query whether the read receipt for a private message is received.

    Query read receipt

    How to determine if the read receipt is received? When msg.scene === 'p2p' && msg.flow === 'out' && msg.time <= session.msgReceiptTime, the read receipt for the message is received.

    Parameters

    Returns boolean

  • isMyFriend(_options: { account: string; done?: any }): void
  • Check if the user is included in the friend list

    Note: This interface requires database support. If the local database is not enabled, the done callback will return false

    Parameters

    Returns void

  • isUserInBlackList(_options: { account: string; done?: any }): void
  • Check if a user is in the blocklist

    Note: This interface requires database support. If the local database is not enabled, the done callback will return false

    Parameters

    Returns void

  • kick(_options: { deviceIds: []; done?: any }): void
  • leaveSuperTeam(_options: { teamId: string; done?: any }): void
  • leaveTeam(_options: { teamId: string; done?: any }): void
  • Return the number of listeners listening to a given event.

    Parameters

    Returns number

  • logout(): void
  • deprecated

    Log out

    Note: For SDK earlier than v9.6.0, it is recommended to logout first and disconnect/destroy to fully exit the chat room.. SDK v9.6.0 and later do not need to call this API, it will be called automatically before disconnect/destroy.

    Returns void

  • markMsgRead(_options: { msgs: NIMMessage[]; done?: any }): void
  • msgFtsInServer(_options: { fromTime?: number; keyword: string; msgLimit?: number; msgSubTypeList?: string[]; msgTypeList?: string[]; order?: string; p2pList?: string[]; senderList?: string[]; sessionLimit?: number; teamList?: string[]; toTime?: number; done?: any }): void
  • Description

    Full-text search for message history on the server. The returned messages will be classified by session, not by time.

    Use cases

    Search message history of all conversations stored on the CommsEase server based on the time range and keywords.

    Prerequisites

    The "full-text search message" setting has been activated in the CommsEase console.

    Configuration: Select the application, and select IM Basic/Pro > Settings > Global > Full-text message search.

    Parameters

    • _options: { fromTime?: number; keyword: string; msgLimit?: number; msgSubTypeList?: string[]; msgTypeList?: string[]; order?: string; p2pList?: string[]; senderList?: string[]; sessionLimit?: number; teamList?: string[]; toTime?: number; done?: any }
      • Optional fromTime?: number

        The start time of the search, the default value 0 means unlimited

      • keyword: string

        Keyword for search

      • Optional msgLimit?: number

        Limit on the number of returned messages per conversation Default value: 5. For example, if you pass 1, each conversation returns 1 matching message.

      • Optional msgSubTypeList?: string[]

        Message subtype, which can be customized when sending messages, and the format is an integer greater than 0. Example: [1, 2]

      • Optional msgTypeList?: string[]

        message type, Example: ['text', 'image', 'audio', 'video', 'geo', 'notification', 'file', 'tip', 'custom']

      • Optional order?: string

        Sorting rule for returned messages. The messages are sorted in descending order DESC by default. optional ASC ascending order.

      • Optional p2pList?: string[]

        Search condition for private chats, account for sessions (p2p-accid1), example: ['accid1', 'accid2', 'accid3']

      • Optional senderList?: string[]

        List of message senders, Example: ['accid1', 'accid2', 'accid3']

      • Optional sessionLimit?: number

        Limit on the number of conversations The default value is 10. For example, if you pass 5, messages in 5 sessions are retrieved and returned

      • Optional teamList?: string[]

        Search condition Group list. Search messages from these groups (team-146694936), example: ['146694936', '13897']

      • Optional toTime?: number

        The end time of the search, the default value is the current time

      • done?:function

    Returns void

  • msgFtsInServerByTiming(_options: { fromTime?: number; keyword: string; msgLimit?: number; msgSubTypeList?: string[]; msgTypeList?: string[]; order?: string; p2pList?: string[]; senderList?: string[]; teamList?: string[]; toTime?: number; done?: any }): void
  • Description

    Full-text search for messages (search by time). the returned messages are sorted in descending order by time.

    Use cases

    Search message history of all conversations stored on the CommsEase server based on the time range and keywords.

    Prerequisites

    The "full-text search message" setting has been activated in the CommsEase console.

    Configuration: Select the application, and select IM Basic/Pro > Settings > Global > Full-text message search.

    Parameters

    • _options: { fromTime?: number; keyword: string; msgLimit?: number; msgSubTypeList?: string[]; msgTypeList?: string[]; order?: string; p2pList?: string[]; senderList?: string[]; teamList?: string[]; toTime?: number; done?: any }
      • Optional fromTime?: number

        The start time of the search, the default value 0 means unlimited

      • keyword: string

        Keyword for search

      • Optional msgLimit?: number

        Limit on the number of returned messages per conversation Default value: 5. For example, if you pass 1, each conversation returns 1 matching message.

      • Optional msgSubTypeList?: string[]

        Message subtype, which can be customized when sending messages, and the format is an integer greater than 0. Example: [1, 2]

      • Optional msgTypeList?: string[]

        message type, Example: ['text', 'image', 'audio', 'video', 'geo', 'notification', 'file', 'tip', 'custom']

      • Optional order?: string

        Sorting rule for returned messages. The messages are sorted in descending order DESC by default. optional ASC ascending order.

      • Optional p2pList?: string[]

        Search condition for private chats, account for sessions (p2p-accid1), example: ['accid1', 'accid2', 'accid3']

      • Optional senderList?: string[]

        List of message senders, Example: ['accid1', 'accid2', 'accid3']

      • Optional teamList?: string[]

        Search condition Group list. Search messages from these groups (team-146694936), example: ['146694936', '13897']

      • Optional toTime?: number

        The end time of the search, the default value is the current time

      • done?:function

    Returns void

  • muteTeamAll(_options: { mute: boolean; teamId: string; done?: any }): void
  • notifyForNewTeamMsg(options: { teamIds: string[]; done: any }): void
  • packFileDownloadName(_options: { name: string; url: string }): string
  • passFriendApply(_options: { account: string; idServer: string; ps?: string; done?: any }): void
  • passSuperTeamApply(_options: { from: string; idServer: string; teamId: string; done?: any }): void
  • An administrator approves the request to join a group.

    If the request is approved:

    1. All group members (except the sender) trigger onmsg:
      • msg.type: 'notification'
      • msg.from: Operator account
      • msg.to: Group ID
      • msg.attach.type: 'passSuperTeamApply'
      • msg.attach.account: Account of the requester
      • msg.attach.members: List of accounts whose requests are approved
    2. All group members get notified by onupdatesessions
    3. All group members get notified by onAddSuperTeamMembers
    4. The function call triggers onupdatesysmsg

    Parameters

    • _options: { from: string; idServer: string; teamId: string; done?: any }
      • from: string

        accountId of the requester

      • idServer: string

        idServer of the notification for join requests.

      • teamId: string
      • done?:function

    Returns void

  • passTeamApply(_options: { from: string; idServer: string; teamId: string; done?: any }): void
  • An administrator approve the request to join a group.

    If the request is approved:

    1. All group members (except the sender) trigger onmsg:
      • msg.type: 'notification'
      • msg.from: Operator account
      • msg.to: Group ID
      • msg.attach.type: 'passTeamApply'
      • msg.attach.account: Account of the requester
      • msg.attach.members: List of accounts whose requests are approved
    2. All group members get notified by onupdatesessions
    3. All group members get notified by onAddTeamMembers
    4. The function call triggers onupdatesysmsg

    Parameters

    • _options: { from: string; idServer: string; teamId: string; done?: any }
      • from: string

        accountId of the requester

      • idServer: string

        idServer of the notification for join requests.

      • teamId: string
      • done?:function

    Returns void

  • Upload and preview files. Send a file message by calling the method.

    Notes

    • Select one of the four parameters fileInput, file, blob, and filePath
    • fileInput: The id of the input element of type='file'. Do not operate the file on this node until the upload is complete
    • file: Parameters of the previewFile callback
    • blob: JavaScript object of blob type
    • filePath: React Native, Mini Program and other special JS runtime environments (the temporary path obtained by chooseImage)

    Notes

    • type: image, audio, video or file. The default value is file. The information contained in the file object in the message body is different
    • image: url, name, size, ext, w, h, type
    • audio: url, name, size, ext, container, dur
    • video: url, name, size, ext, container, dur, w, h
    • file: url, name, size, ext

    Notes

    • A maximum of 100MB for the file size is allowed
    • Advanced browsers will detect the file size before uploading
    • IE8/IE9 will detect the file size after uploading

    Parameters

    Returns void

  • processImage(_options: { ops: NIMStrAnyObj; url: string; done?: any }): void
  • Process an image

    This method receives a set of image operations, and processes the images in order of operations. The optional operations include:

    • Modify the image quality
    • interlace image
    • Rotate an image
    • apply Gaussian blurring
    • crop the image
    • generate a thumbnail
    • preview the file
    • send a file message

    For the parameters required for each operation, see the above methods. In addition to the parameters listed in the above methods, each operation needs to provide the operation types:

    • 'quality'
    • 'interlace'
    • 'rotate'
    • 'blur'
    • 'crop'
    • 'thumbnail'

    Code sample

    // Rotate after cropping
    var url = 'http://nim.nos.netease.com/MTAxMTAwMg==/bmltYV8xNDc5OTNfMTQ0MzE0NTgyNDI0M184YjFkYTMwMS02NjcxLTRiYjktYTUwZC04ZTVlZjZlNzZjMzA=';
    nim.processImage({
    url: url,
    ops: [
    {
    type: 'crop',
    x: 100,
    y: 0,
    width: 250,
    height: 250,
    },
    {
    type: 'thumbnail',
    mode: 'cover',
    width: 80,
    height: 80
    }
    ],
    done: processImageDone
    });
    function processImageDone(error, obj) {
    console.log('Processing the image' + (!error?'success':'failure'), error, obj);
    }

    Parameters

    • _options: { ops: NIMStrAnyObj; url: string; done?: any }
      • ops: NIMStrAnyObj

        Operation sequence. Process images sequentially according to the order of operations. For the specific format, see the previous image processing interfaces

        Similar effects

        [ { type: 'crop', x: 100, y: 0, width: 250, height: 250, }, { type: 'thumbnail', mode: 'cover', width: 80, height: 80 } ]

      • url: string
      • done?:function

    Returns void

  • publishEvent(_options: { broadcastType?: number; custom?: string; sync?: boolean; type: number; validTime?: number; value: number; done?: any }): void
  • When an event is published, subscribers will get notified by onpushevents.

    Events are divided into two categories:

    1. Online presence status, used to monitor the online presence status of friends. During initialization, the online presence event will only be subscribed the account is online
      • type = 1, value = 1: Online
      • type = 1, value = 2: Logout
      • type = 1, value = 3: Disconnected
    2. Custom events If the built-in online presence status event cannot meet the requirements, You needs some custom events. You can publish custom events using this API. User-defined events must be type = 1, value >= 10000

    Associated function

    Parameters

    • _options: { broadcastType?: number; custom?: string; sync?: boolean; type: number; validTime?: number; value: number; done?: any }
      • Optional broadcastType?: number

        broadcast broadcast types

        1: Online users only 2: Online and offline users

      • Optional custom?: string

        Custom event extension property

      • Optional sync?: boolean

        Specify whether to sync the broadcast message for the current user

      • type: number

        Event type, only 1 is available.

      • Optional validTime?: number

        The validity time of published events in seconds, 60s~7 days (604800s), and the default value is 7 days

      • value: number

        Event status/event content, custom mapping is supported.

        Note: the value must be greater than 10000 (1-9999 is the predefined value range for CommsEase, 1: online, 2: offline, 3: disconnected.

      • done?:function

    Returns void

  • qualityImage(_options: { quality: number; url: string; done?: any }): void
  • Modify the image quality

    • Only support image URLs obtained by previewing files or sending file messages, or image URLs obtained after other image operations.
    • The default image quality is 100. You can reduce the picture quality to save data usage for apps.

    Parameters

    • _options: { quality: number; url: string; done?: any }
      • quality: number

        Image quality, integer, value range: 0-100

      • url: string

        Original URL to the image stored in NOS

      • done?:function

    Returns void

  • querySubscribeEventsByAccounts(_options: { accounts: string[]; type: number; done?: any }): void
  • querySubscribeEventsByType(_options: { type: number; done?: any }): void
  • recallMsg(_options: { apnsText?: string; attach?: string; env?: string; msg: NIMMessage; ps?: string; pushPayload?: string; done?: any }): void
  • Description

    Unsend a message.

    Use cases

    Within the validity time after a message is sent (2 minutes by default, which can be configured in the CommsEase console), the sender can unsend the sent private message or group message.

    • If a message is unsent, the message will not be stored for offline messages, messages for sync and message history, and the recipient will receive a system notification of type deleteMsg.
    • In group chats, all group members will receive a system notification of type deleteMsg.
    • If the sender has logged in the same IM account on multiple devices at the same time, the other devices will also receive a system notification of type deleteMsg.

    Notes

    Unsending a messages in private chats is different from group chats:

    • Private chat: a user can unsend a sent message.
    • Group chat: regular members can unsend messages sent by themselves. Administrators can unsend messages sent by other group members.

    Limit

    • If the message fails to be sent or the message sender is blocked, it cannot be unsent even within the validity time.
    • After the message is unsent, neither the sender nor the recipient can find the message in the message history, messages for sync or offline messages.
    • In the following cases, unsending a message will fail: an empty message, the message is not sent successfully, the validity time for unsending a message expirest, or the message is hit by moderation rules.

    Associated function

    Example

    Parameters

    • _options: { apnsText?: string; attach?: string; env?: string; msg: NIMMessage; ps?: string; pushPayload?: string; done?: any }
      • Optional apnsText?: string

        Custom text for push notifications

      • Optional attach?: string

        Additional information, JSON string is recommended

      • Optional env?: string

        Environment for messaging webhooks

      • msg: NIMMessage

        message to be unsent

      • Optional ps?: string

        Additional message

      • Optional pushPayload?: string

        Custom properties for push notifications, must be JSON string.

      • done?:function

    Returns void

  • rejectFriendApply(_options: { account: string; idServer: string; ps: string; done?: any }): void
  • rejectSuperTeamApply(_options: { from: string; idServer: string; ps?: string; teamId: string; done?: any }): void
  • an administrator rejects a request to join a group

    If a request is reject:

    • the requester gets notified by onsysmsg
      • from: Account that rejects the request
      • to: Group ID
      • attach: Group information
    • the function triggers onupdatesysmsg

    Parameters

    • _options: { from: string; idServer: string; ps?: string; teamId: string; done?: any }
      • from: string

        accountId of the requester

      • idServer: string

        idServer of the notification for join requests.

      • Optional ps?: string

        Additional Information

      • teamId: string
      • done?:function

    Returns void

  • rejectSuperTeamInvite(_options: { from: string; idServer: string; ps?: string; teamId: string; done?: any }): void
  • Reject the invitation to join a group

    A user rejects the invitation:

    • the inviter will receive a system notification onsysmsg
      • type: 'rejectSuperTeamInvite'
      • from: Account that rejects the invitation
      • to: Group ID
    • the function triggers onupdatesysmsg

    Parameters

    • _options: { from: string; idServer: string; ps?: string; teamId: string; done?: any }
      • from: string

        accountId of the requester

      • idServer: string

        idServer of the notification for invitation from an administrator.

      • Optional ps?: string

        Additional Information

      • teamId: string
      • done?:function

    Returns void

  • rejectTeamApply(_options: { from: string; idServer: string; ps?: string; teamId: string; done?: any }): void
  • an administrator rejects a request to join a group

    If a request is reject:

    • the requester gets notified by onsysmsg
      • from: Account that rejects the request
      • to: Group ID
      • attach: Group information
    • the function triggers onupdatesysmsg

    Parameters

    • _options: { from: string; idServer: string; ps?: string; teamId: string; done?: any }
      • from: string

        accountId of the requester

      • idServer: string

        idServer of the notification for join requests.

      • Optional ps?: string

        Additional Information

      • teamId: string
      • done?:function

    Returns void

  • rejectTeamInvite(_options: { from: string; idServer: string; ps?: string; teamId: string; done?: any }): void
  • Reject the invitation to join a group

    A user rejects the invitation:

    • the inviter will receive a system notification onsysmsg
      • type: 'rejectTeamInvite'
      • from: Account that rejects the invitation
      • to: Group ID
    • the function triggers onupdatesysmsg

    Parameters

    • _options: { from: string; idServer: string; ps?: string; teamId: string; done?: any }
      • from: string

        accountId of the requester

      • idServer: string

        idServer of the notification for invitation from an administrator.

      • Optional ps?: string

        Additional Information

      • teamId: string
      • done?:function

    Returns void

  • Remove all listeners, or those of the specified event.

    Parameters

    Returns NIM

  • removeFromBlacklist(_options: { account: string; done?: any }): void
  • Remove from blocklist The onblacklist callback is triggered during initialization and onsyncmarkinblacklist triggered during synchronization across devices.

    Example

    Parameters

    • _options: { account: string; done?: any }
      • account: string
      • done?:function
        • done(err: null | NIMCommonError | Error | NIMStrAnyObj, data: { account: string; isAdd: boolean; record: { account: string; updateTime: number } }): void
        • Parameters

          • err: null | NIMCommonError | Error | NIMStrAnyObj
          • data: { account: string; isAdd: boolean; record: { account: string; updateTime: number } }
            • account: string

              Target account ID

            • isAdd: boolean

              Whether the account is included in the blocklist or the list of muted members.

              true: Yes, false: No.

            • record: { account: string; updateTime: number }

              Details of the operation record

              • account: string

                Target account ID

              • updateTime: number

                Update timestamp

          Returns void

    Returns void

  • removeFromMutelist(_options: { account: string; done?: any }): void
  • Remove from the list of muted users. The onmutelist callback is triggered during initialization and onsyncmarkinmutelist triggered during synchronization across devices.

    The list of muted users:

    1. determine whether to display the unread count on the UI.
    2. Does not trigger the push service for messages sent by users in the list.

    Example

    Parameters

    • _options: { account: string; done?: any }
      • account: string
      • done?:function
        • done(err: null | NIMCommonError | Error | NIMStrAnyObj, data: { account: string; isAdd: boolean; record: { account: string; updateTime: number } }): void
        • Parameters

          • err: null | NIMCommonError | Error | NIMStrAnyObj
          • data: { account: string; isAdd: boolean; record: { account: string; updateTime: number } }
            • account: string

              Target account ID

            • isAdd: boolean

              Whether the account is included in the blocklist or the list of muted members.

              true: Yes, false: No.

            • record: { account: string; updateTime: number }

              Details of the operation record

              • account: string

                Target account ID

              • updateTime: number

                Update timestamp

          Returns void

    Returns void

  • removeSuperTeamManagers(_options: { accounts: string[]; teamId: string; done?: any }): void
  • Remove an administrator

    If administrators are added:

    1. All group members (except the sender) trigger onmsg:
      • msg.type: 'notification'
      • msg.from: Account that removes an administrator
      • msg.to: Group ID
      • msg.attach.type: 'removeSuperTeamManagers'
      • msg.attach.accounts: List of removed administrators
      • msg.attach.members: Detailed information about removed administrators
    2. All group members get notified by onupdatesessions
    3. All members get notified by onUpdateSuperTeamManagers

    Parameters

    Returns void

  • removeSuperTeamMembers(_options: { accounts: string[]; teamId: string; done?: any }): void
  • Remove a member

    1. All group members (except the sender) trigger onmsg:
      • msg.type: 'notification'
      • msg.from: The operator account
      • msg.to: Group ID
      • msg.attach.type: 'removeSuperTeamMembers'
      • msg.attach.team: Group details
      • msg.attach.accounts: The array of removed accounts
    2. All group members get notified by onupdatesessions
    3. All team members get notified by onRemoveSuperTeamMembers

    Parameters

    • _options: { accounts: string[]; teamId: string; done?: any }

    Returns void

  • removeTeamManagers(_options: { accounts: string[]; teamId: string; done?: any }): void
  • Remove an administrator

    If administrators are added:

    1. All group members (except the sender) trigger onmsg:
      • msg.type: 'notification'
      • msg.from: Account that removes an administrator
      • msg.to: Group ID
      • msg.attach.type: 'removeTeamManagers'
      • msg.attach.accounts: List of removed administrators
      • msg.attach.members: Detailed information about removed administrators
    2. All group members get notified by onupdatesessions
    3. All members get notified by onUpdateTeamManagers

    Parameters

    Returns void

  • removeTeamMembers(_options: { accounts: string[]; teamId: string; done?: any }): void
  • Remove a member

    1. All group members (except the sender) trigger onmsg:
      • msg.type: 'notification'
      • msg.from: The operator account
      • msg.to: Group ID
      • msg.attach.type: 'removeTeamMembers'
      • msg.attach.team: Group details
      • msg.attach.accounts: The array of removed accounts
    2. All group members get notified by onupdatesessions
    3. All team members get notified by onRemoveTeamMembers

    Parameters

    • _options: { accounts: string[]; teamId: string; done?: any }

    Returns void

  • resetAllSessionUnread(): void
  • resetCurrSession(_sessionId: string): void
  • resetSessionUnread(_sessionId: string, _done: (err: null | Error, failedSessionId: string) => void): void
  • resetSessionsUnread(_sessionIds: string[], _done: (err: null | Error) => void): Promise<void>
  • resetSuperTeamSessionsUnread(_sessionIds: string[], _done: (err: null | Error) => void): Promise<void>
  • rotateImage(_options: { angle: number; url: string; done?: any }): void
  • Rotate an image

    • Only support image URLs obtained by previewing files or sending file messages, or image URLs obtained after other image operations.

    Parameters

    • _options: { angle: number; url: string; done?: any }
      • angle: number

        Rotation angle

      • url: string

        Original URL to the image stored in NOS

      • done?:function

    Returns void

  • saveMsgsToLocal(_options: { msgs: NIMMessage[]; done?: any }): void
  • searchLocal(_options: { keyPath?: "session" | "session.lastMsg.type" | "session.id" | "session.scene" | "session.lastMsg.text" | "session.localCustom" | "session.target.account" | "session.target.nick" | "session.target.alias" | "session.target.name" | "user" | "user.account" | "user.nick" | "user.alias"; keyword: string; done?: any }): void
  • Parameters

    • _options: { keyPath?: "session" | "session.lastMsg.type" | "session.id" | "session.scene" | "session.lastMsg.text" | "session.localCustom" | "session.target.account" | "session.target.nick" | "session.target.alias" | "session.target.name" | "user" | "user.account" | "user.nick" | "user.alias"; keyword: string; done?: any }
      • Optional keyPath?: "session" | "session.lastMsg.type" | "session.id" | "session.scene" | "session.lastMsg.text" | "session.localCustom" | "session.target.account" | "session.target.nick" | "session.target.alias" | "session.target.name" | "user" | "user.account" | "user.nick" | "user.alias"

        Path for search. If unspecified, all fields below will be searched

      • keyword: string

        Keyword for search

      • done?:function

    Returns void

  • Description

    If the capabilities provided by the SDK don't meet your business needs, this interface can send custom message in private or group chats, such as rock-paper-scissors and dice-throwing.

    Notes

    This interface returns the message body in the sending state, and the sent message body needs to be obtained by passing options.done.

    Scope

    Calling this API can trigger:

    1. NIMGetInstanceOptions.onmsg for recipients
    2. NIMGetInstanceOptions.onupdatesessions for recipients
    3. NIMGetInstanceOptions.onupdatesessions for the sender
    4. NIMGetInstanceOptions.onmsg for the concurrent logged-in devices of the sender

    Example

    Example

    nim.sendCustomMsg({
    scene: 'p2p',
    to: 'account',
    //The recipient receives the message using onMsg
    //if msg.type === 'custom', the recipient reads msg.content and then calls the business code
    content: JSON.stringify({type: 1}),
    done: function(err, msg) {
    if (err) {
    console.log('Failed to send the message', err)
    } else {
    console.log('Message sent: ', msg)
    }
    }
    })

    Parameters

    Returns NIMMessage

  • 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
  • Send a custom system notification

    Note, the difference between custom system notification (sendCustoSysmMsg) and custom message (sendCustomMsg) is as follows:

    1. The custom message belongs to NIMMessage, stored in the CommsEase server, delivered to the app server along with other messages, and message history can be queried.
    2. Custom system notifications belongs to NIMSystemMessage, used for notifications on the client, and will not be stored in the CommsEase server, and the history cannot be queried. The SDK only deliver these notifications.

    Example

    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

        Custom content for APNS service for system notifications, only valid for recipients of iOS devices.

      • Optional cc?: boolean

        Whether the notification is synced using sync webhook. The default value is true

      • content: string

        Custom content of the system message, JSON serialized string recommended.

      • Optional env?: string

        The environment variable pointing to different types of configurations for state sync and third-party callbacks.

      • Optional isPushable?: boolean

        Whether push notifications is required . Default value: true

      • Optional needPushNick?: boolean

        Whether the nickname is required for push notifications. The default value is false.

      • Optional pushPayload?: string

        Custom content of the system notification, JSON serialized string recommended.

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

        Scenarios are divided into private chat(p2p), group chat(team), and supergroup chat(superTeam).

      • Optional sendToOnlineUsersOnly?: boolean

        Whether to send notifications only to online users. The default value is true.

        true. Only sent to online users, if the receiver is not online, this notification will be discarded. It is suitable for the scene of "typing indicators"

        false. If the recipient is online, the notification will be received immediately. If the recipient is not online, an system notification will be pushed after the recipient goes online.

      • to: string

        Recipient account ID, or group ID.

      • done?:function

    Returns void

  • Description

    Send image, video, audio or other files. You can upload and send a file by calling `sendFile`. You can also upload the file first by calling `previewFile` and send the file by invoking `sendFile`.

    Notes

    • Since SDK v8.9.102 and v9.7.0, this interface returns the message body in the sending state, and the sent message body can be obtained by passing options.done.

    Note 2

    • Select one of the four parameters fileInput, file, blob, and filePath
    • fileInput: The ID of the input element with type='file'. Please do not operate the file on this node until the upload is complete
    • file: Parameters of the previewFile callback
    • blob: JS object of blob type
    • filePath: Runtime environments (the temporary path obtained by chooseImage) for React Native, applets

    Note 3

    • type: image, audio, video or file. Default value: file. The information contained in the file object in the message body is different
    • image: url, name, size, ext, w, h, type
    • audio: url, name, size, ext, container, dur
    • video: url, name, size, ext, container, dur, w, h
    • file: url, name, size, ext

    Scope

    Calling this API can trigger:

    1. NIMGetInstanceOptions.onmsg for recipients
    2. NIMGetInstanceOptions.onupdatesessions for recipients
    3. NIMGetInstanceOptions.onupdatesessions for the sender
    4. NIMGetInstanceOptions.onmsg for the concurrent logged-in devices of the sender

    Send files & resend files

    nim.sendFile({
    scene: 'p2p',
    to: 'account',
    type: 'image',
    fileInput: 'domId',
    done: function(err, obj) {
    if (err) {
    console.log('Failed to send the message', err)
    // Resend a message. When the file upload fails, the msg of the obj parameter has a message body, and in other cases, the obj is the message body.
    setTimeout(function () {
    resendMessage(obj.msg ? obj.msg : obj)
    }, 3000)
    } else {
    console.log('Message sent: ', obj)
    }
    }
    })

    // Get the idClient for rendering before uploading
    console.log(message.idClient)

    // Resend the message
    function resendMessage(oldMessage) {
    nim.sendFile(Object.assign(oldMessage, {
    scene: 'p2p',
    to: 'account',
    type: 'image',
    fileInput: 'domId',
    resend: true, // Note that this resend is set to true, so that the idClient in oldMessage can be used permanently
    done: function(err, obj) {
    if (err) {
    console.log('Failed to send the message', err)
    } else {
    console.log('Message sent: ', obj)
    }
    }
    }))
    }

    first PreviewFile and send the file

    nim.previewFile({
    type: 'image',
    fileInput: fileInput,
    uploadprogress: function(obj) {
    console.log('file size: ' + obj.total + 'bytes');
    console.log('uploaded size: ' + obj.loaded + 'bytes');
    console.log('Upload progress: ' + obj.percentage);
    console.log('Upload progress in percentage: ' + obj.percentageText);
    },
    done: function(error, file) {
    console.log('Uploading the image' + (!error?'success':'failure'));
    // show file to the user
    if (!error) {
    var msg = nim.sendFile({
    scene: 'p2p',
    to: 'account',
    file: file,
    done: sendMsgDone
    });
    console.log('Sending the image message , id=' + msg.idClient);
    pushMsg(msg);
    }
    }
    })

    Related links

    Parameters

    Returns NIMMessage

  • Description

    Send a geolocation message to target users, groups, or supergroups.

    Notes

    This interface returns the message body in the sending state, and the sent message body needs to be obtained by passing options.done.

    Scope

    Calling this API can trigger:

    1. NIMGetInstanceOptions.onmsg for recipients
    2. NIMGetInstanceOptions.onupdatesessions for recipients
    3. NIMGetInstanceOptions.onupdatesessions for the sender
    4. NIMGetInstanceOptions.onmsg for the concurrent logged-in devices of the sender

    Example

    nim.sendGeo({
    scene: 'p2p',
    to: 'account',
    //The recipient receives the message using onMsg
    //if msg.type === 'geo', the recipient reads msg.geo, and then calls the business code
    geo: {
    lng: 116.3833,
    lat: 39.9167,
    title: 'Beijing'
    },
    done: function(err, msg) {
    if (err) {
    console.log('Failed to send the message', err)
    } else {
    console.log('Message sent: ', msg)
    }
    }
    })

    Parameters

    Returns NIMMessage

  • sendMsgReceipt(_options: { msg: NIMMessage; done?: any }): void
  • sendTeamMsgReceipt(_options: { teamMsgReceipts: { idClient?: string; idServer: string; teamId: string }[]; done?: any }): void
  • Description

    Send read receipt for group messages. If the sender is online and has registered onTeamMsgReceipt during initialization, the client will receive a notification that the group message has been read.

    Notes

    Note that the sender must set needMsgReceipt = true before the recipient can send the read receipt for the group message.

    There are two ways to receive read receipts:

    1. When initializing the SDK and logging in, the time of read receipts of a conversation is synchronized with NIMGetInstanceOptions.syncMsgReceipts = true.
    2. If other users send read receipts, monitor the latest read receipt time of the conversation using NIMGetInstanceOptions.onTeamMsgReceipt.

    Scope

    Calling this API method triggers: onTeamMsgReceipt callback

    Example

    Example

    //Message sender
    nim.sendText({
    scene: 'team',
    to: 'teamId',
    text: "Hello",
    // Note that this field must be set to true
    needMsgReceipt: true
    })

    // Recipient
    nim.sendTeamMsgReceipt({
    teamMsgReceipts: [{
    teamId: 'teamId',
    idClient: 'xxxx',
    idServer: 'yyyy'
    }]
    })

    Parameters

    • _options: { teamMsgReceipts: { idClient?: string; idServer: string; teamId: string }[]; done?: any }
      • teamMsgReceipts: { idClient?: string; idServer: string; teamId: string }[]

        List of group messages whose read receipt to be sent

      • done?:function

    Returns void

  • Description

    Send an alert a target user, group, or supergroup. Alerts are sent for notifications in a conversation. Typical use cases include welcome messages when joining a group or tips when hitting keywords for moderation in chats.

    Notes

    This interface returns the message body in the sending state, and the sent message body needs to be obtained by passing options.done.

    Scope

    Calling this API can trigger:

    1. NIMGetInstanceOptions.onmsg for recipients
    2. NIMGetInstanceOptions.onupdatesessions for recipients
    3. NIMGetInstanceOptions.onupdatesessions for the sender
    4. NIMGetInstanceOptions.onmsg for the concurrent logged-in devices of the sender

    Example

    nim.sendTipMsg({
    scene: 'p2p',
    to: 'account',
    //The recipient receives the message using onMsg
    //if msg.type === 'tip', the recipient reads msg.tip, and then calls the business code
    tip: 'tip content',
    done: function(err, msg) {
    if (err) {
    console.log('Failed to send the message', err)
    } else {
    console.log('Message sent: ', msg)
    }
    }
    })

    Parameters

    Returns NIMMessage

  • setCurrSession(_sessionId: string): void
  • Set "join the current conversation"

    Note: This is an easy-to-use composite interface . The logic is: record the current conversation in memory, call resetSessionUnread to clear the unread count when joining the conversation, and use resetSessionUnread to clear the unread count when new messages are received onMsg.

    • If it is not suitable for your use case, you can combine the APIs. Caution when the onupdatesessions change triggered by receiving a new message. the change of the unread count of the current conversation is ignored.

    Associated function

    Parameters

    • _sessionId: string

    Returns void

  • Update the initialization parameters of the original NIM instance. The configurable parameters are the same as those of the NIM.getInstance method.

    Use cases

    Any scenario that needs to update parameters for initialization. For example:

    • When a dynamic token is used to log in, the dynamic token, update a dynamic token by this API.
    • When using a static token to log in, refresh and update the static token using this API.

    For details about IM login, see initialization and login IM.

    Parameters

    Returns void

  • signalingAccept(_options: { account: string; attachExt?: string; autoJoin?: boolean; channelId: string; joinAttachExt?: string; offlineEnabled?: boolean; requestId: string; uid?: number }): Promise<void>
  • Accept an invitation to join a channel.

    Parameters

    • _options: { account: string; attachExt?: string; autoJoin?: boolean; channelId: string; joinAttachExt?: string; offlineEnabled?: boolean; requestId: string; uid?: number }
      • account: string

        ID of the account that sends the invitation

      • Optional attachExt?: string

        The additional information of the operation sent to others

      • Optional autoJoin?: boolean

        Whether to join the channel directly by accepting the invitation. true by default

      • channelId: string

        Channel ID

      • Optional joinAttachExt?: string

        Additional Information for joining a channel, The information is included in the notification sent to other members.

      • Optional offlineEnabled?: boolean

        Whether the message is stored for offline users. The default value is false

      • requestId: string

        Request ID must be specified by the inviter and is used for canceling, rejecting, or accepting invitations.

      • Optional uid?: number

        UID of the current user in the channel The value must be greater than 0. If the uid becomes invalid, the server will assign a random uid.

    Returns Promise<void>

  • signalingCall(_options: { account: string; attachExt?: string; channelName: string; ext?: string; offlineEnabled?: boolean; pushInfo?: NIMSignalingPushInfo; requestId: string; type: number; uid?: string }): Promise<NIMSignalingChannel>
  • Join an audio and video call. Create and join a channel, and invite the peer to join the channel

    Note that this is a combined interface, equivalent to calling signalingCreateAndJoin and signalingInvite.

    Parameters

    • _options: { account: string; attachExt?: string; channelName: string; ext?: string; offlineEnabled?: boolean; pushInfo?: NIMSignalingPushInfo; requestId: string; type: number; uid?: string }
      • account: string

        ID of an invited member

      • Optional attachExt?: string

        The additional information of the operation is passed to the invited user

      • channelName: string

        Channel name

      • Optional ext?: string

        Extension field

      • Optional offlineEnabled?: boolean

        Whether the message is stored for offline users. The default value is false

      • Optional pushInfo?: NIMSignalingPushInfo

        Properties of a push notification

      • requestId: string

        Request ID must be specified by the inviter and is used for canceling, rejecting, or accepting invitations.

      • type: number

        Channel type, call type 1: Audio; 2: video; 3: Others

      • Optional uid?: string

        The uid of the current user in the channel. The value must be greater than 0. If the ID becomes invalid, the server will assign a random uid.

    Returns Promise<NIMSignalingChannel>

  • signalingCallEx(_options: { account: string; attachExt?: string; channelName: string; ext?: string; nertcChannelName?: string; nertcJoinRoomQueryParamMap?: string; nertcTokenTtl?: string; offlineEnabled?: boolean; pushInfo?: NIMSignalingPushInfo; requestId: string; type: number; uid?: string }): Promise<NIMSignalingChannel>
  • Join an audio and video call. Create and join a channel, and invite the peer to join the channel

    Note that this is a combined interface with parameters for audio and video calling compared with signalingCall.

    Parameters

    • _options: { account: string; attachExt?: string; channelName: string; ext?: string; nertcChannelName?: string; nertcJoinRoomQueryParamMap?: string; nertcTokenTtl?: string; offlineEnabled?: boolean; pushInfo?: NIMSignalingPushInfo; requestId: string; type: number; uid?: string }
      • account: string

        ID of an invited member

      • Optional attachExt?: string

        The additional information of the operation is passed to the invited user

      • channelName: string

        Channel name

      • Optional ext?: string

        Extension field

      • Optional nertcChannelName?: string

        The name of an RTC room. the SDK will take this parameter when joining the channel, and return the token

      • Optional nertcJoinRoomQueryParamMap?: string

        Parameters for requests to join an RTC room. Serialized data in JSON is recommended

      • Optional nertcTokenTtl?: string

        The validity period of the token, indicating the expiration time of the token, in seconds, optional. The default duration is 10 minutes.

      • Optional offlineEnabled?: boolean

        Whether the message is stored for offline users. The default value is false

      • Optional pushInfo?: NIMSignalingPushInfo

        Properties of a push notification

      • requestId: string

        Request ID must be specified by the inviter and is used for canceling, rejecting, or accepting invitations.

      • type: number

        Channel type, call type 1: Audio; 2: video; 3: Others

      • Optional uid?: string

        The uid of the current user in the channel. The value must be greater than 0. If the ID becomes invalid, the server will assign a random uid.

    Returns Promise<NIMSignalingChannel>

  • signalingCancel(_options: { account: string; attachExt?: string; channelId: string; offlineEnabled?: boolean; requestId: string }): Promise<void>
  • Cancel an invitation

    Parameters

    • _options: { account: string; attachExt?: string; channelId: string; offlineEnabled?: boolean; requestId: string }
      • account: string

        ID of an invited member

      • Optional attachExt?: string

        The additional information of the operation is passed to the invited user

      • channelId: string

        Channel ID

      • Optional offlineEnabled?: boolean

        Whether the message is stored for offline users. The default value is false

      • requestId: string

        Request ID must be specified by the inviter and is used for canceling, rejecting, or accepting invitations.

    Returns Promise<void>

  • signalingClose(_options: { attachExt?: string; channelId: string; offlineEnabled?: boolean }): Promise<void>
  • Close a channel

    Parameters

    • _options: { attachExt?: string; channelId: string; offlineEnabled?: boolean }
      • Optional attachExt?: string

        The additional information of the operation sent to others

      • channelId: string

        Channel ID

      • Optional offlineEnabled?: boolean

        Whether the message is stored for offline users. The default value is false

    Returns Promise<void>

  • signalingControl(_options: { account?: string; attachExt?: string; channelId: string }): Promise<void>
  • Send a custom signal

    Parameters

    • _options: { account?: string; attachExt?: string; channelId: string }
      • Optional account?: string

        Target account (account id) to be notified If unspecified, all members are notified

      • Optional attachExt?: string

        The additional information of the operation sent to others

      • channelId: string

        Channel ID

    Returns Promise<void>

  • signalingCreate(_options: { channelName: string; ext?: string; type: number }): Promise<NIMSignalingChannel>
  • Create a channel.

    Parameters

    • _options: { channelName: string; ext?: string; type: number }
      • channelName: string

        Channel name

      • Optional ext?: string

        Extension field

      • type: number

        Channel type, call type 1: Audio; 2: video; 3: Others

    Returns Promise<NIMSignalingChannel>

  • signalingCreateAndJoin(_options: { attachExt?: string; channelName: string; ext?: string; offlineEnabled?: boolean; type: number; uid?: string }): Promise<NIMSignalingChannel>
  • If the room does not exist, create and join a channel. If the channel already exists, join the channel.

    Note that this is a combined interface, equivalent to calling signalingCreate and signalingJoin.

    Parameters

    • _options: { attachExt?: string; channelName: string; ext?: string; offlineEnabled?: boolean; type: number; uid?: string }
      • Optional attachExt?: string

        The additional information of the operation is passed to the invited user

      • channelName: string

        Channel name

      • Optional ext?: string

        Extension field

      • Optional offlineEnabled?: boolean

        Whether the message is stored for offline users. The default value is false

      • type: number

        Channel type, call type 1: Audio; 2: video; 3: Others

      • Optional uid?: string

        The uid of the current user in the channel. The value must be greater than 0. If the ID becomes invalid, the server will assign a random uid.

    Returns Promise<NIMSignalingChannel>

  • Extend the expiration time of a channel

    Note that SDK v9.8.0 supports automatic extension of the expiration time of a channel.

    Parameters

    • _options: { channelId: string }
      • channelId: string

        Unique channel ID

    Returns Promise<NIMSignalingChannel>

  • signalingInvite(_options: { account: string; attachExt?: string; channelId: string; offlineEnabled?: boolean; pushInfo?: NIMSignalingPushInfo; requestId: string }): Promise<void>
  • Invite a user to join the channel.

    Parameters

    • _options: { account: string; attachExt?: string; channelId: string; offlineEnabled?: boolean; pushInfo?: NIMSignalingPushInfo; requestId: string }
      • account: string

        ID of an invited member

      • Optional attachExt?: string

        The additional information of the operation is passed to the invited user

      • channelId: string

        Channel ID

      • Optional offlineEnabled?: boolean

        Whether the message is stored for offline users. The default value is false

      • Optional pushInfo?: NIMSignalingPushInfo

        Properties of a push notification

      • requestId: string

        Request ID must be specified by the inviter and is used for canceling, rejecting, or accepting invitations.

    Returns Promise<void>

  • signalingJoin(_options: { attachExt?: string; channelId: string; offlineEnabled?: boolean; uid?: number }): Promise<NIMSignalingChannel>
  • Join a channel

    Parameters

    • _options: { attachExt?: string; channelId: string; offlineEnabled?: boolean; uid?: number }
      • Optional attachExt?: string

        The additional information of the operation sent to others

      • channelId: string

        Channel ID

      • Optional offlineEnabled?: boolean

        Whether the message is stored for offline users. The default value is false

      • Optional uid?: number

        The uid of the current user in the channel. The value must be greater than 0. If the ID becomes invalid, the server will assign a random uid.

    Returns Promise<NIMSignalingChannel>

  • signalingJoinAndAccept(_options: { account: string; attachExt?: string; channelId: string; nertcChannelName?: string; nertcJoinRoomQueryParamMap?: string; nertcTokenTtl?: number; offlineEnabled?: boolean; requestId: string; uid?: number }): Promise<void>
  • Join a channel and accept an invitation. This interface combines two interfaces, equivalent to joining a channel and accepting an invitation

    Parameters

    • _options: { account: string; attachExt?: string; channelId: string; nertcChannelName?: string; nertcJoinRoomQueryParamMap?: string; nertcTokenTtl?: number; offlineEnabled?: boolean; requestId: string; uid?: number }
      • account: string

        Peer accid, required

      • Optional attachExt?: string

        The additional information of the operation sent to others

      • channelId: string

        Channel ID

      • Optional nertcChannelName?: string

        The name of an RTC room. the SDK will take when joining the channel, and return the token

      • Optional nertcJoinRoomQueryParamMap?: string

        Parameters for requests to join an RTC room. Serialized data in JSON is recommended

      • Optional nertcTokenTtl?: number

        The validity period of the token, indicating the expiration time of the token, in seconds, optional. The default duration is 10 minutes.

      • Optional offlineEnabled?: boolean

        Whether notifications are required for offline messages. The default value is false

      • requestId: string

        Required, the request ID must be specified by the inviter and is used for canceling, rejecting, or Required< accepting invitations.

      • Optional uid?: number

        The uid of the current user in the channel. The value must be greater than 0. If the ID becomes invalid, the server will assign a random uid.

    Returns Promise<void>

  • signalingLeave(_options: { attachExt?: string; channelId: string; offlineEnabled?: boolean }): Promise<void>
  • Parameters

    • _options: { attachExt?: string; channelId: string; offlineEnabled?: boolean }
      • Optional attachExt?: string

        The additional information of the operation sent to others

      • channelId: string

        Channel ID

      • Optional offlineEnabled?: boolean

        Whether the message is stored for offline users. The default value is false

    Returns Promise<void>

  • signalingMarkMsgRead(_options: { msgid: string[] | number[] }): Promise<void>
  • Mark the message read. The message will not be received as offline messages.

    Parameters

    • _options: { msgid: string[] | number[] }
      • msgid: string[] | number[]

        ID of a signaling message that needs to be marked.

    Returns Promise<void>

  • signalingReject(_options: { account: string; attachExt?: string; channelId: string; offlineEnabled?: boolean; requestId: string }): Promise<void>
  • Reject an invitation to join a channel.

    Parameters

    • _options: { account: string; attachExt?: string; channelId: string; offlineEnabled?: boolean; requestId: string }
      • account: string

        ID of the account that sends the invitation

      • Optional attachExt?: string

        The additional information of the operation sent to others

      • channelId: string

        Channel ID

      • Optional offlineEnabled?: boolean

        Whether the message is stored for offline users. The default value is false

      • requestId: string

        Request ID must be specified by the inviter and is used for canceling, rejecting, or accepting invitations.

    Returns Promise<void>

  • signalingSync(): Promise<void>
  • Returns Promise<void>

  • stripImageMeta(_options: { url: string; done: any }): string
  • Remove the metadata of an image

    • Only support image URLs obtained by previewing files or sending file messages, or image URLs obtained after other image operations.
    • Image without meta information will not contain EXIF information

    Parameters

    Returns string

  • subscribeEvent(_options: { accounts: string[]; subscribeTime?: number; sync?: boolean; type: number; done?: any }): void
  • Subscribes to events published by specified users Whether it is a built-in online status event or a custom event, you must subscribe to the event using this API.

    Notes

    • Each IM account can subscribe up to 3000 other IM accounts
    • Subscription on other devices will overwrite the validity period of the subscription on the current device. Therefore, it is recommended that the subscription duration of each client be consistent
    • If you subscribe to the same event for the same account within 30 seconds, the target event will not be triggered even if the service is synchronous.

    Associated function

    Example

    Parameters

    • _options: { accounts: string[]; subscribeTime?: number; sync?: boolean; type: number; done?: any }

    Returns void

  • thumbnailImage(_options: { axis: { x: number; y: number }; height?: number; url: string; width?: number; done?: any }): void
  • Generate the thumbnails of an image

    • Only support image URLs obtained by previewing files or sending file messages, or image URLs obtained after other image operations.
    • The value of width/height limits the size of the thumbnail. - The value of width/height must be greater than or equal to 0, cannot be 0 at the same time, and must be less than 4096
    • The thumbnails generated in different modes are different, currently the following three modes are supported:
    • 'cover': The original image is scaled in proportion, one side of the thumbnail is equal to the requested size, and the other side is larger than the requested size, that is, the thumbnail can just cover the rectangle with the size of width*height
    • 'contain': The original image is proportional to the thumbnail, one side of the thumbnail is equal to the requested size, and the other side is larger than the requested size, that is, a rectangle with a size of width*height can just cover the thumbnail
    • 'crop': First get the thumbnail based on the original image proportionally so that one side is equal to the requested size and the other side is larger than the requested size, and then crop the side larger than the requested size so that the final image size is exactly equal to the requested size (Note: the crop mode does not support thumbnails to GIFs)
    • If the size of the thumbnail is larger than the size of the picture, the picture will not be enlarged by default, you can pass the parameter `enlarge= true to enlarge the picture.
    • In 'crop' mode, parameters axis.x or axis.y can be used to control the position of the last cropping step.
    • The value X and Y must be integers, the value range is 0-10. This method internally uses Math.round to format x/y.
    • If X is set to 0, the leftmost side is cropped and if X is set tos 10, the rightmost side is cropped
    • If Y is 0, it means to crop the top. If Y is 10, it means to crop the bottom.
    • The default value of x/y is 5, that is, cut the middle

    Parameters

    • _options: { axis: { x: number; y: number }; height?: number; url: string; width?: number; done?: any }
      • axis: { x: number; y: number }

        Coordinates for cropping

        • x: number

          C coordinate, must be an integer

        • y: number

          Y coordinate, must be an integer

      • Optional height?: number

        Height of an thumbnail

      • url: string

        Original URL to the image stored in NOS

      • Optional width?: number

        Width of an thumbnail

      • done?:function

    Returns void

  • transferSuperTeam(_options: { account: string; leave: boolean; teamId: string; done?: any }): void
  • Transfer the ownership of a supergroup. The group owner can perform the action

    • Notifications for transferring the ownership of a group
    1. All group members (except the sender) trigger onmsg:
      • msg.type: 'notification'
      • msg.from: Account that transfers the ownership of a group.
      • msg.to: Group ID
      • msg.attach.type: 'transferSuperTeam'
      • msg.attach.team: Group details
      • msg.attach.account: New group owner
      • msg.attach.members: List of group members including the original group owner and the new group owner
    2. All group members get notified by onupdatesessions
    3. All team members get notified by onTransferSuperTeam
    • If you leave the group while transferring the group, you directly leave the group.
    1. All group members (except the sender) trigger onmsg:
      • msg.type: 'notification'
      • msg.attach.type: 'leaveSuperTeam'
    2. All group members get notified by onupdatesessions
    3. All team members get notified by onRemoveSuperTeamMembers

    Parameters

    • _options: { account: string; leave: boolean; teamId: string; done?: any }
      • account: string
      • leave: boolean

        Whether to leave the group while transferring the ownership of the group

      • teamId: string
      • done?:function

    Returns void

  • transferTeam(_options: { account: string; leave: boolean; teamId: string; done?: any }): void
  • Transfer the ownership of a group, the group owner can perform the action

    • Notifications for transferring the ownership of a group
    1. All group members (except the sender) trigger onmsg:
      • msg.type: 'notification'
      • msg.from: Account that transfers the ownership of a group.
      • msg.to: Group ID
      • msg.attach.type: 'transferTeam'
      • msg.attach.team: Group details
      • msg.attach.account: New group owner
      • msg.attach.members: List of group members including the original group owner and the new group owner
    2. All group members get notified by onupdatesessions
    3. All team members get notified by onTransferTeam
    • If you leave the group while transferring the group, you directly leave the group.
    1. All group members (except the sender) trigger onmsg:
      • msg.type: 'notification'
      • msg.attach.type: 'leaveTeam'
    2. All group members get notified by onupdatesessions
    3. All team members get notified by onRemoveTeamMembers

    Parameters

    • _options: { account: string; leave: boolean; teamId: string; done?: any }
      • account: string
      • leave: boolean

        Whether to leave the group while transferring the ownership of the group

      • teamId: string
      • done?:function

    Returns void

  • unSubscribeEventsByAccounts(_options: { accounts?: string[]; type: number; done?: any }): void
  • unSubscribeEventsByType(_options: { type: number; done?: any }): void
  • updateCollect(_options: { collect: NIMCollect; done?: any }): void
  • updateFriend(_options: { account: string; alias?: string; custom?: string; done?: any }): void
  • updateInfoInSuperTeam(_options: { custom?: string; muteNotiType?: string; muteTeam?: boolean; nickInTeam?: string; teamId: string; done?: any }): void
  • Edit the profile of the current user

    Parameters

    • _options: { custom?: string; muteNotiType?: string; muteTeam?: boolean; nickInTeam?: string; teamId: string; done?: any }
      • Optional custom?: string

        Extension field

      • Optional muteNotiType?: string

        Alert strategy

        "0": turn on alerts "1": turn off alerts "2": turn on alerts for notifications from administrators

      • Optional muteTeam?: boolean
        deprecated

        use "muteNotiType" instead

        Whether to turn off alerts for this group, The default value is false

        Note: The value true means to turn off the alert, but the SDK can still receive the messages. The SDK just records this setting, and the specific operation to be performed is based on your requirements.

      • Optional nickInTeam?: string

        Nickname in a group

        Note: After updating the nickname, all other online group members will get notified byonupdateteammember.

      • teamId: string
      • done?:function

    Returns void

  • updateInfoInTeam(_options: { custom?: string; muteNotiType?: string; muteTeam?: boolean; nickInTeam?: string; teamId: string; done?: any }): void
  • Edit the profile of the current user in the group

    Example

    Parameters

    • _options: { custom?: string; muteNotiType?: string; muteTeam?: boolean; nickInTeam?: string; teamId: string; done?: any }
      • Optional custom?: string

        Extension field

      • Optional muteNotiType?: string

        Alert strategy

        "0": turn on alerts "1": turn off alerts "2": turn on alerts for notifications from administrators

      • Optional muteTeam?: boolean
        deprecated

        use "muteNotiType" instead

        Whether to turn off alerts for this group, The default value is false

        Note: The value true means to turn off the alert, but the SDK can still receive the messages. The SDK just records this setting, and the specific operation to be performed is based on your requirements.

      • Optional nickInTeam?: string

        Nickname in a group

        Note: After updating the nickname, all other online group members will get notified byonupdateteammember.

      • teamId: string
      • done?:function

    Returns void

  • updateLocalMsg(_options: { idClient: string; localCustom: string; done?: any }): void
  • Description

    Update local messages. Only localCustom local custom extension fields are allowed to be updated.

    Notes

    If the runtime environment does not support the database, or the database is not running, the execution is successful, but no valid data will be returned.

    Parameters

    Returns void

  • updateLocalSession(_options: { id: string; localCustom?: string; needNotify?: boolean; done?: any }): void
  • updateLocalSysMsg(_options: { idServer: string; localCustom?: string; state?: string; done?: any }): void
  • updateMsgPin(_options: { msg: NIMMsgPinInfo; pinCustom?: string; done?: any }): void
  • updateMuteStateInTeam(_options: { account: string; mute: boolean; teamId: string; done?: any }): void
  • Update the mute state of a member

    1. All group members (except the sender) trigger onmsg:
      • msg.type: 'notification'
      • msg.from: Operator
      • msg.to: Group ID
      • msg.attach.type: 'updateTeamMute'
      • msg.attach.account: Muted account
      • msg.attach.members: List of muted members
    2. All group members get notified by onupdatesessions
    3. All group members get notified by onUpdateTeamMembersMute

    Example

    Parameters

    • _options: { account: string; mute: boolean; teamId: string; done?: any }

    Returns void

  • updateMyInfo(_options: { antiSpamBusinessId?: string; avatar?: string; birth?: string; custom?: string; email?: string; gender?: "unknown" | "male" | "female"; nick?: string; sign?: string; tel?: string; done?: any }): void
  • Update the profile of the current user. The onmyinfo callback is triggered during initialization and onupdatemyinfo triggered during synchronization across devices.

    Example

    Parameters

    • _options: { antiSpamBusinessId?: string; avatar?: string; birth?: string; custom?: string; email?: string; gender?: "unknown" | "male" | "female"; nick?: string; sign?: string; tel?: string; done?: any }
      • Optional antiSpamBusinessId?: string

        Business ID for moderation

      • Optional avatar?: string

        avatar

      • Optional birth?: string

        date of birth

      • Optional custom?: string

        Extension field

      • Optional email?: string

        Email

      • Optional gender?: "unknown" | "male" | "female"

        Gender

      • Optional nick?: string

        Nickname

      • Optional sign?: string

        Signature

      • Optional tel?: string

        Phone number

      • done?:function

    Returns void

  • updateNickInSuperTeam(_options: { account: string; nickInTeam: string; teamId: string; done?: any }): void
  • updateNickInTeam(_options: { account: string; nickInTeam: string; teamId: string; done?: any }): void
  • updateServerSession(_options: { extra: string; scene: "p2p" | "team" | "superTeam"; to: string; done: any }): void
  • updateSessionsWithMoreRoaming(_options: { msg: NIMMessage; done?: any }): void
  • updateStickTopSession(_options: { id: string; topCustom?: string; done: any }): void
  • updateSuperTeam(_options: { announcement?: string; antiSpamBusinessId?: string; avatar?: string; beInviteMode?: "noVerify" | "needVerify"; custom?: string; intro?: string; inviteMode?: "manager" | "all"; joinMode?: "noVerify" | "needVerify" | "rejectAll"; name: string; teamId: string; updateCustomMode?: "manager" | "all"; updateTeamMode?: "manager" | "all"; done?: any }): void
  • Update the supergroup profile

    1. All group members (except the sender) trigger onmsg:
      • msg.type: 'notification'
      • msg.from: Operator account
      • msg.to: Group ID
      • msg.attach.type: 'updateSuperTeam'
      • msg.attach.team: Group details
    2. All group members get notified by onupdatesessions
    3. All team members get notified by onUpdateSuperTeam

    Parameters

    • _options: { announcement?: string; antiSpamBusinessId?: string; avatar?: string; beInviteMode?: "noVerify" | "needVerify"; custom?: string; intro?: string; inviteMode?: "manager" | "all"; joinMode?: "noVerify" | "needVerify" | "rejectAll"; name: string; teamId: string; updateCustomMode?: "manager" | "all"; updateTeamMode?: "manager" | "all"; done?: any }
      • Optional announcement?: string

        Group announcement

      • Optional antiSpamBusinessId?: string

        Business ID for moderation configured in the CommsEase console.

      • Optional avatar?: string

        Group avatar

      • Optional beInviteMode?: "noVerify" | "needVerify"

        Verification method for invitations

      • Optional custom?: string

        Extension field

      • Optional intro?: string

        Group introduction

      • Optional inviteMode?: "manager" | "all"

        Invitation mode

      • Optional joinMode?: "noVerify" | "needVerify" | "rejectAll"

        Join method

      • name: string

        Group name

      • teamId: string

        Group ID

      • Optional updateCustomMode?: "manager" | "all"

        Permissions for editing custom fields of a group profile

      • Optional updateTeamMode?: "manager" | "all"

        Permissions for editing the group profile

      • done?:function

    Returns void

  • updateSuperTeamMembersMute(_options: { account: string; mute: boolean; teamId: string; done?: any }): void
  • Update the mute state of a member

    1. All group members (except the sender) trigger onmsg:

      • msg.type: 'notification'
      • msg.from: Operator
      • msg.to: Group ID
      • msg.attach.type: 'updateSuperTeamMembersMute'
      • msg.attach.team: Group details
      • msg.attach.account: Muted account
      • msg.attach.members: List of muted members
    2. All group members get notified by onupdatesessions

    3. All group members get notified by onUpdateSuperTeamMembersMute

    Parameters

    • _options: { account: string; mute: boolean; teamId: string; done?: any }

    Returns void

  • updateSuperTeamMute(_options: { mute: boolean; teamId: string; done?: any }): void
  • Mute all supergroup members

    1. All group members (except the sender) trigger onmsg:
      • msg.type: 'notification'
      • msg.from: Operator account
      • msg.to: Group ID
      • msg.attach.type: 'updateSuperTeam'
      • msg.attach.team: Group details
    2. All group members get notified by onupdatesessions
    3. All team members get notified by onUpdateSuperTeam

    Parameters

    Returns void

  • updateTeam(_options: { announcement?: string; antiSpamBusinessId?: string; avatar?: string; beInviteMode?: "noVerify" | "needVerify"; custom?: string; intro?: string; inviteMode?: "manager" | "all"; joinMode?: "noVerify" | "needVerify" | "rejectAll"; name: string; teamId: string; updateCustomMode?: "manager" | "all"; updateTeamMode?: "manager" | "all"; done?: any }): void
  • Update the group profile.

    Basic group limits

    For basic groups, this group profile cannot be updated - Join method - Invitation verification type - Invitation mode - Group profile permission - Group profile custom field permission

    Functions

    1. All group members (except the sender) trigger onmsg:
      • msg.type: 'notification'
      • msg.from: Operator account
      • msg.to: Group ID
      • msg.attach.type: 'updateTeam'
      • msg.attach.team: Group details
    2. All group members get notified by onupdatesessions
    3. All team members get notified by onUpdateTeam

    Parameters

    • _options: { announcement?: string; antiSpamBusinessId?: string; avatar?: string; beInviteMode?: "noVerify" | "needVerify"; custom?: string; intro?: string; inviteMode?: "manager" | "all"; joinMode?: "noVerify" | "needVerify" | "rejectAll"; name: string; teamId: string; updateCustomMode?: "manager" | "all"; updateTeamMode?: "manager" | "all"; done?: any }
      • Optional announcement?: string

        Group announcement

      • Optional antiSpamBusinessId?: string

        Business ID for moderation configured in the CommsEase console.

      • Optional avatar?: string

        Group avatar

      • Optional beInviteMode?: "noVerify" | "needVerify"

        Verification method for invitations

      • Optional custom?: string

        Extension field

      • Optional intro?: string

        Group introduction

      • Optional inviteMode?: "manager" | "all"

        Invitation mode

      • Optional joinMode?: "noVerify" | "needVerify" | "rejectAll"

        Join method

      • name: string

        Group name

      • teamId: string

        Group ID

      • Optional updateCustomMode?: "manager" | "all"

        Permissions for editing custom fields of a group profile

      • Optional updateTeamMode?: "manager" | "all"

        Permissions for editing the group profile

      • done?:function

    Returns void

    • This interface is implemented in singleton mode. For the same account, the same instance will always be returned.
    • Subsequent calls to this interface will directly return the initialized instance, and will also call the interface setOptions to update with the new configuration
    • If the connection is closed, the connection will be established automatically.
    • SDK will automatically reconnect when the client gets disconnected.

    Parameters

    Returns NIM