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 ChatClient is about to change its state.

    Implement this method when you want to react before the ChatClient change 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 currentState parameter

    Declaration

    Swift

    @objc(chatClientWillChangeState:oldState:newState:)
    optional func chatClientWillChangeState(_ client: ChatClient, oldState: ChatClientState, newState: ChatClientState)

    Parameters

    client

    The chat client object.

    oldState

    The state the chat client is about to leave.

    newState

    The state the chat client is about to transition to.

  • A method invoked when the ChatClient changed its state.

    Implement this method when you want to react after the ChatClient changed 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

    client

    The chat client object.

    oldState

    The state the chat client was in before the transition occurred.

    newState

    The state the chat client transitioned to.

  • An optional method invoked when the ChatClient has failed.

    Implement this method when you want to react after the ChatClient has 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

    client

    The chat client object.

    error

    The error occurred.