BCHChatClient

Objective-C

@protocol BCHChatClient <NSObject>

Swift

protocol BCHChatClient : NSObjectProtocol

It’s the main item required to connect to the Chat platform.

Client state

Observer

  • @brief Adds an observer that will be notified synchronously on a private background queue. @discussion The observer object will be held weakly.

    Declaration

    Objective-C

    - (void)addObserver:(nonnull id<BCHChatClientObserver>)observer;

    Parameters

    observer

    The observer to be added.

  • @brief Adds an observer specifying on which dispatch queue it must be notified.

    @discussion If a nil queue is provided the observer will be notified synchronously on a private background queue. Otherwise the observer will be notified asynchronously on the queue provided.

    The observer will be held weakly.

    Declaration

    Objective-C

    - (void)addObserver:(nonnull id<BCHChatClientObserver>)observer
                  queue:(nullable dispatch_queue_t)queue;

    Parameters

    observer

    The observer to add.

    queue

    The dispatch queue onto which the observer will be notified.

  • Removes a client observer.

    Declaration

    Objective-C

    - (void)removeObserver:(nonnull id<BCHChatClientObserver>)observer;

    Parameters

    observer

    The observer to be removed.

Starting, stopping the client

  • Start the client, connecting it to bandyer’s platform.

    @remarks Throws an NSInvalidArgumentException when passing a blank user id as parameter.

    Declaration

    Objective-C

    - (void)start:(nonnull NSString *)userId;

    Swift

    func start(userId: String)

    Parameters

    userId

    The user alias of the user.

  • @brief Resumes the client, reconnecting it to bandyer’s platform, after the client has been paused first. @discussion You should call this method after the client has been paused, for example you might resume the client when the app returns in foreground.

    Declaration

    Objective-C

    - (void)resume;

    Swift

    func resume()
  • @brief Pause the client, disconnecting it from bandyer’s platform. @discussion You should call this method when you want to stop the client from detecting incoming messages and sending outgoing messages, for example you might pause the client when the app goes in background.

    Declaration

    Objective-C

    - (void)pause;

    Swift

    func pause()
  • @brief Stop the client, disconnecting it from bandyer’s platform. You should stop it when app is going to be terminated. @discussion Once the client has been stopped, you must start it once again calling [BCHChatClient start:] method if you want to reuse it.

    Declaration

    Objective-C

    - (void)stop;

    Swift

    func stop()