QNChatsRepository

public class QNChatsRepository

Service to manage chat actions and subscribe to chat events

Api

  • connect() Asynchronous

    Starts a new chat session, new messages are delivered once it’s connected

    Declaration

    Swift

    public func connect() async throws
  • disconnect() Asynchronous

    Remove a chat session, this should be called on logout

    Declaration

    Swift

    public func disconnect() async
  • suspend() Asynchronous

    Stops a chat session, this should be called when enters in background to receive pushes via apn

    Declaration

    Swift

    public func suspend() async
  • reconnectSession() Asynchronous

    Reconnects a chat session, this should be called when enters in foreground to receive pushes via socket tcp

    Declaration

    Swift

    public func reconnectSession() async throws
  • Enable push module to receive new chat notifications

    Declaration

    Swift

    public func enablePushNotification(apnsToken: String, sessionToken: String, serverJID: String) async throws

    Parameters

    apnsToken

    APNS token

    sessionToken

    Token from server session

    serverJID

    Server to register the push

  • Disable push module to stop receiving new chat notifications

    Declaration

    Swift

    public func disablePushNotification(sessionToken: String, serverJID: String) async throws

    Parameters

    sessionToken

    Token from server session

    serverJID

    Server to register the push

  • Create a new chat

    Declaration

    Swift

    public func createChat(creationType: QNChatsRepository.CreationType) async throws -> QNChatRepository

    Parameters

    creationType

    Used to create a 1-1 chat or a group chat

    result

    Async result with Chat

  • Fetch chats

    Declaration

    Swift

    public func chats(
        types: [QNChatRepository.ChatType],
        fetchingDataChat: Bool = true
    ) async throws -> [QNChatRepository]

    Parameters

    types

    Filter by type (1-1 or group)

    result

    Async result with a list of Chat

  • joinGroupChat(id:) Asynchronous

    Join a specific group chat

    Declaration

    Swift

    public func joinGroupChat(id: String) async throws -> QNChatRepository

    Parameters

    id

    Identifier of the chat to be joined

    result

    Async result with the Chat