ChatClient
public class ChatClient
ChatClient class for ChatThread operations.
-
Undocumented
Declaration
Swift
public weak var pushNotificationKeyStorage: PushNotificationKeyStorage?
-
Create a ChatClient.
Declaration
Swift
public init( endpoint: String, credential: CommunicationTokenCredential, withOptions userOptions: AzureCommunicationChatClientOptions ) throws
Parameters
endpoint
The Communication Services endpoint.
credential
The user credential.
userOptions
Options used to configure the client.
-
Create a ChatThreadClient for the ChatThread with id threadId.
Declaration
Swift
public func createClient(forThread threadId: String) throws -> ChatThreadClient
Parameters
threadId
The threadId.
-
Create a new ChatThread.
Declaration
Swift
public func create( thread: CreateChatThreadRequest, withOptions options: CreateChatThreadOptions? = nil, completionHandler: @escaping HTTPResultHandler<CreateChatThreadResult> )
Parameters
thread
Request for creating a chat thread with the topic and optional members to add.
options
Create chat thread options.
completionHandler
A completion handler that receives a ChatThreadClient on success.
-
Gets the list of ChatThreads for the user.
Declaration
Swift
public func listThreads( withOptions options: ListChatThreadsOptions? = nil, completionHandler: @escaping HTTPResultHandler<PagedCollection<ChatThreadItem>> )
Parameters
options
List chat threads options.
completionHandler
A completion handler that receives the list of chat thread items on success.
-
Delete the ChatThread with id chatThreadId.
Declaration
Swift
public func delete( thread threadId: String, withOptions options: DeleteChatThreadOptions? = nil, completionHandler: @escaping HTTPResultHandler<Void> )
Parameters
threadId
The chat thread id.
options
Delete chat thread options.
completionHandler
A completion handler.
-
Start receiving realtime notifications. Call this function before subscribing to any event.
Declaration
Swift
public func startRealTimeNotifications(completionHandler: @escaping (Result<Void, AzureError>) -> Void)
Parameters
completionHandler
Called when starting notifications has completed.
-
Stop receiving realtime notifications. This function would unsubscribe to all events.
Declaration
Swift
public func stopRealTimeNotifications()
-
Subscribe to chat events.
Declaration
Swift
public func register( event: ChatEventId, handler: @escaping TrouterEventHandler )
Parameters
event
The chat event to subsribe to.
handler
The handler for the chat event.
-
Unsubscribe to chat events.
Declaration
Swift
public func unregister( event: ChatEventId )
Parameters
event
The chat event to unsubsribe from.
-
Start push notifications. Receiving of notifications can be expected after successfully registering.
Declaration
Swift
public func startPushNotifications( deviceToken: String, completionHandler: @escaping (Result<HTTPResponse?, AzureError>) -> Void )
Parameters
deviceToken
APNS push token.
completionHandler
Success indicates request to register for notifications has been received.
-
Stop push notifications.
Declaration
Swift
public func stopPushNotifications( completionHandler: @escaping (Result<HTTPResponse?, AzureError>) -> Void )
Parameters
completionHandler
Success indicates push notifications have been stopped.