QNChatRepository

public class QNChatRepository

Represents a chat

  • Define wether a chat is a group or not

    • oneToOne
    • groupChat

    Declaration

    Swift

    public enum ChatType

Properties

  • Expose chat type (1-1 or group)

    Declaration

    Swift

    public var type: ChatType { get }
  • Chat identifier (remote user for 1-1 and UUID for group chats)

    Declaration

    Swift

    public var identifier: String { get }
  • Group actions for group chats like invite a participant or expel one

    Declaration

    Swift

    public private(set) var groupChatActions: QNGroupChatActions? { get }
  • Last message received

    Declaration

    Swift

    public fileprivate(set) var lastMessage: QNChatMessage? { get set }
  • Count of unread messages

    Declaration

    Swift

    public fileprivate(set) var unreadMessagesCount: Int { get set }
  • Title of chat

    Declaration

    Swift

    public fileprivate(set) var title: String { get }
  • Image URL of chat

    Declaration

    Swift

    public fileprivate(set) var imageUrl: URL? { get }
  • Chat is associated with a conference

    Declaration

    Swift

    public var isConferenceChat: Bool { get }

Api

  • Fetch history related to this user, messages are received in delegate

    Declaration

    Swift

    public func fetchMessagesFromStore(messageSearch: QNChatMessageSearch,
                                       retrieveFromCache: Bool = false) async throws -> [QNChatMessage]

    Parameters

    messageSearch

    search criteria

    retrieveFromCache

    should retrieve from cache.

    completion

    completion block with QNChatMessageSearchResult

  • Send participant action, like typing or active, to remote participant

    Declaration

    Swift

    public func sendParticipantActionInChat(_ action: QNChatMessage.ParticipantAction)

    Parameters

    action

    Current participant action

  • send(message:) Asynchronous

    Sends a new message to other participant

    Declaration

    Swift

    public func send(message: String) async throws -> QNChatMessage

    Parameters

    message

    Body message to be sent

    Return Value

    A Message

  • Sends multiple files to the chat concurrently.

    This method manages the entire XMPP file sharing lifecycle (slot request, HTTP upload, and XMPP message delivery) for each file in parallel.

    Declaration

    Swift

    public func send(
        files: [QNUploadFile],
        progressHandler: ((String, Float) -> Void)? = nil
    ) async -> SendFilesReport

    Parameters

    files

    An array of QNUploadFile objects representing the files to be sent. Each object should contain the raw data, the filename, and optionally the local path.

    progressHandler

    An optional closure to track the upload progress of each individual file. It provides the filename (String) and the current progress (Float, ranging from 0.0 to 1.0).

    Return Value

    A SendFilesReport tuple containing an array of successfully sent messages (successful) and an array of files that failed along with their respective errors (failed).

  • Mark a message with a new status

    Declaration

    Swift

    public func mark(message: QNChatMessage, as status: QNChatMessage.Status)

    Parameters

    message

    Message to change status

    status

    New status

  • Send a mark with last message read

    Declaration

    Swift

    public func markChatAsRead()
  • archive() Asynchronous

    Archive chat

    Declaration

    Swift

    public func archive() async throws
  • delete() Asynchronous

    Delete chat

    Declaration

    Swift

    public func delete() async throws