Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface SessionInterface

Hierarchy

  • SessionInterface

Implemented by

Index

Methods

  • addStickTopSession(options: { id: string; topCustom?: string; done: any }): void
  • deleteLocalSession(options: { id: string; isDeleteRoaming?: boolean; isLogic?: boolean; done?: any }): void
  • Delete the specified conversation from the local database. and optionally delete messages for sync on the server.

    Associated function

    Example

    Parameters

    • options: { id: string; isDeleteRoaming?: boolean; isLogic?: boolean; done?: any }
      • id: string

        Conversation ID

      • Optional isDeleteRoaming?: boolean

        Whether to delete messages for sync, default value: false. Added from v8.2.0, if true, the server will not send messages for sync in this conversation next time you sign in. This setting will affect logins on other devices. Proceed with caution.

      • Optional isLogic?: boolean

        Whether the conversation is deleted by logic. The default value is false. New feature from V7.9.1, data marked as deleted but the actual data is not immediately removed from the physical storage. The unread and msgReceiptTime of the conversation are reserved. The next time the conversation is created, correct unread count and read timestamps are kept.

      • done?:function

    Returns 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
  • 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

        value: false. search starts from the earliest conversations.

        true: search starts from the conversations with the latest update time

      • done:function

    Returns void

  • getSessionsWithMoreRoaming(options: { id: string; done?: any }): void
  • getStickTopSessions(options: { done: any }): 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

  • resetAllSessionUnread(): void
  • resetCurrSession(sessionId: string): void
  • Cancels the effect of "setCurrSession". After cancellation, the unread count will change after the conversation receives new messages.

    Associated function

    Parameters

    • sessionId: string

    Returns void

  • resetSessionUnread(sessionId: string, done: (err: null | Error, failedSessionId: string) => void): void
  • Reset the unread count for a conversation. To reset the unread count of a superTeamSessionsUnread, use SessionInterface.resetSuperTeamSessionsUnread.

    Notes

    Parameters

    • sessionId: string
    • done: (err: null | Error, failedSessionId: string) => void
        • (err: null | Error, failedSessionId: string): void
        • Parameters

          • err: null | Error
          • failedSessionId: string

          Returns void

    Returns void

  • resetSessionsUnread(sessionIds: string[], done: (err: null | Error) => void): Promise<void>
  • resetSuperTeamSessionsUnread(sessionIds: string[], done: (err: null | Error) => void): Promise<void>
  • Reset the unread count for some supergroups

    Notes

    Parameters

    • sessionIds: string[]
    • done: (err: null | Error) => void
        • (err: null | Error): void
        • Parameters

          • err: null | Error

          Returns void

    Returns Promise<void>

  • 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

  • updateLocalSession(options: { id: string; localCustom?: string; needNotify?: boolean; done?: any }): void
  • Update conversations in the local database

    Parameters

    • options: { id: string; localCustom?: string; needNotify?: boolean; done?: any }
      • id: string

        Conversation ID

      • Optional localCustom?: string

        local custom extension field

      • Optional needNotify?: boolean

        whether to trigger onupdatesession or onupdatesessions callback, the default value is true

      • done?:function

    Returns void

  • updateSessionsWithMoreRoaming(options: { msg: NIMMessage; done?: any }): void
  • updateStickTopSession(options: { id: string; topCustom?: string; done: any }): void