To initialise the SDK, you will need a few pre-requisites.

  • A configured API Space

  • authentication provider that can generate a JWT that matches the auth scheme configured for your API Space.

  • Implementation of the ChatStore. This implementation should perform db inserts and updates in a single transaction. Set a factory class for ChatStore objects in configuration object.

ChatConfig config = new ChatConfig()

authenticator needs to extend ComapiAuthenticator class

authenticator = new ComapiAuthenticator() {
    public void onAuthenticationChallenge(AuthClient authClient, 
       ChallengeOptions options) {
          // get token using options.getNonce()

store factory needs to extend StoreFactory class

store = new StoreFactory<ChatStore>() {
      protected void build(StoreCallback<ChatStore> callback) {
        // create ChatStore implementation that suppeort single tranasaction mechanism

to initialise SDK and obtain client instance as a result (you will be responsible for storing the client instance in the app)

ComapiChat.initialise(application, chatConfig, new Callback<ComapiChatClient>(){/* implement */});

if you would like the SDK to store a static instance for you use below initialise method instead

ComapiChat.initialiseShared(application, chatConfig, new Callback<ComapiChatClient>(){/* implement */});

// to get the client instance somwhere else

if you prefer reactive APIs then you can use one of these

ComapiChat.initialise(application, chatConfig).subscribe(new Action1<ComapiChatClient>(){/* implement */}, 
      new Action1<Throwable>(){/* implement */});


ComapiChat.initialiseShared(application, chatConfig)
 .subscribe(new Action1<ComapiChatClient>(){/* implement */}, 
      new Action1<Throwable>(){/* implement */});