ChatClientObserver
@available(iOS 12.0, *)
@objc(BDKChatClientObserver)
public protocol ChatClientObserver : NSObjectProtocol
An observer of a chat client object.
You subscribe as a ChatClientObserver when you want to react about ChatClient object state changes.
You are required to implement at least the chatClientDidChangeState(_:oldState:newState:) method invoked after the ChatClient has changed its state
-
An optional method invoked when the
ChatClientis about to change its state.Implement this method when you want to react before the
ChatClientchange its internal state. This method provides the current state of the client and the new state the client will transition to.Important
If you subscribe as an asynchronous observer, the current state you are going to get from the client parameter won’t match the value from the
currentStateparameterDeclaration
Swift
@objc(chatClientWillChangeState:oldState:newState:) optional func chatClientWillChangeState(_ client: ChatClient, oldState: ChatClientState, newState: ChatClientState)Parameters
clientThe chat client object.
oldStateThe state the chat client is about to leave.
newStateThe state the chat client is about to transition to.
-
A method invoked when the
ChatClientchanged its state.Implement this method when you want to react after the
ChatClientchanged its internal state. This method provides the new state the client has transitioned to and the old state the client was in before the transition occurred.Declaration
Swift
@objc(chatClientDidChangeState:oldState:newState:) func chatClientDidChangeState(_ client: ChatClient, oldState: ChatClientState, newState: ChatClientState)Parameters
clientThe chat client object.
oldStateThe state the chat client was in before the transition occurred.
newStateThe state the chat client transitioned to.
-
An optional method invoked when the
ChatClienthas failed.Implement this method when you want to react after the
ChatClienthas failed, getting the cause of the failure as a method parameter.Declaration
Swift
@objc(chatClient:didFailWithError:) optional func chatClient(_ client: ChatClient, didFailWithError error: Error)Parameters
clientThe chat client object.
errorThe error occurred.
View on GitHub
ChatClientObserver Protocol Reference