QNChatsRepository
public class QNChatsRepository
Service to manage chat actions and subscribe to chat events
-
Data needed to create each type of chat
- oneToOne
- groupChat
Declaration
Swift
public enum CreationType
-
Chats associated to active conferences
Declaration
Swift
public var currentConferenceChats: [QNChatRepository] { get }
-
Current active chats
Declaration
Swift
public var currentChats: [QNChatRepository] { get }
-
Add a new
QNChatsDelegate
Declaration
Swift
public func add(delegate: QNChatsDelegate)
Parameters
delegate
delegate instance
-
Remove a
QNChatsDelegate
Declaration
Swift
public func remove(delegate: QNChatsDelegate)
Parameters
delegate
delegate to remove
-
Starts a new chat session, new messages are delivered once it’s connected
Declaration
Swift
public func connect(completion: @escaping () -> Void)
Parameters
completion
completion block
-
Remove a chat session, this should be called on logout
Declaration
Swift
public func disconnect(completion: @escaping () -> Void)
Parameters
completion
completion block
-
Stops a chat session, this should be called when enters in background to receive pushes via apn
Declaration
Swift
public func suspend(completion: @escaping () -> Void)
Parameters
completion
completion block
-
Reconnects a chat session, this should be called when enters in foreground to receive pushes via socket tcp
Declaration
Swift
public func reconnectSession(completion: @escaping () -> Void)
Parameters
completion
completion block
-
Enable push module to receive new chat notifications
Declaration
Swift
public func enablePushNotification(apnsToken: String, sessionToken: String, serverJID: String, completion: @escaping (Result<Void, ClientError>) -> Void)
Parameters
apnsToken
APNS token
sessionToken
Token from sippo session
serverJID
Server to register the push
completion
completion block
-
Disable push module to stop receiving new chat notifications
Declaration
Swift
public func disablePushNotification(sessionToken: String, serverJID: String, completion: @escaping (Result<Void, ClientError>) -> Void)
Parameters
sessionToken
Token from sippo session
serverJID
Server to register the push
completion
completion block
-
Create a new chat
Declaration
Swift
public func createChat(creationType: QNChatsRepository.CreationType, result: @escaping (Result<QNChatRepository, ResourceError>) -> Void)
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], result: @escaping (Result<[QNChatRepository], ResourceError>) -> Void)
Parameters
types
Filter by type (1-1 or group)
result
Async result with a list of
Chat
-
Join a specific group chat
Declaration
Swift
public func joinGroupChat(id: String, result: @escaping (Result<QNChatRepository, ResourceError>) -> Void)
Parameters
id
Identifier of the chat to be joined
result
Async result with the
Chat