-
Notifications
You must be signed in to change notification settings - Fork 0
Chat client life cycle
The following guide will teach you how to handle the conversation lifecycle for the 4.0 version, if you are looking for the 3.x version take a look a this guide instead.
The lifecycle of the Kaleyra Video conversation begins after the configuration of the SDK. Once the SDK is configured, a conversation object will be created and it will be accessible from the KaleyraVideo singleton instance. When the SDK is told to start connecting, it will try to connect to the KaleyraVideo platform and the conversation object state will change reflecting the state of the connection with its services.
In order to be notified about conversation connection state changes, you can and you should subscribe as a subscriber to the conversation statePublisher. The following code listing will show you how to subscribe as subscriber of the conversation state publisher:
KaleyraVideo.instance.conversation?.statePublisher.removeDuplicates().receive(on: DispatchQueue.main).sink { state in
debugPrint("Conversation state changed \(state)")
}.store(in: &subscriptions)
Note
Subscribers will be notified on a background queue unless you subscribe to a different scheduler
Looking for other platforms? Take a look at Android, Flutter, ReactNative, Ionic / Cordova. Anything unclear or inaccurate? Please let us know by submitting an Issue or write us here.