Mesibo Real-time Chat APIs - Initialization

You need to call one or more initialization APIs before using any other mesibo APIs. Following are the various Initialization APIs.


This API is for Android only.

This is the first API function you must call before you use any other mesibo APIs.

void init(context);

init takes the following parameters:

contextApplication Context

Media and Database Path [Optional]

By default, mesibo automatically chooses the path suitable to your device to store all the files and database. You can change the path using the setPath API. The default Path will be used if this API is not called or the path is not writable. It is recommended to use the default path or check that the path is writable before calling this API.

void setPath(String path);

setPath takes the following parameters:

pathValid file system path. Ensure that your app has permission to read/write to this path

Set User Credentials

Set the access token for the user. Refer to the back-end APIs to learn how your backend can generate an access token.

int setAccessToken(String token);

setAccessToken takes the following parameters:

tokenUser Access Token Obtained using Backend APIs

The access token must be generated specifically for the particular application using the backend API. The setAccessToken API will fail if the access token was generated for a different app. Refer to the appid described in the token generation section of back-end APIs. You can also use utility function Mesibo.getAppIdForAccessToken() to know about the App ID associated with the app.

Setting up a Database to Store Messages

Enable a local database to store all incoming & outgoing messages, profiles, and other information. If this API is not called, Mesibo will not use any local database to store messages. Note that many APIs depends on the database and they will not work if the database is not set up.

It is recommended to call setDatabase after setting the user access token using setAccessToken API. It ensures a unique local database for each user. If setDatabase is called before setAccessToken API function, the same local database will be used for all the users.

boolean setDatabase(String dbname);

setDatabase takes the following parameters:

dbnameName, or the complete path of the database. If the path is not specified, the database will be stored in the default path or the path set by setPath API

Add Listener

Mesibo invokes listeners for various events. For example, when you receive a message, receive an incoming call, connection status, etc. You can implement these listeners to get real-time event notifications. Listeners are described in various sections in the API documentation.

You can add a listener using 'addListener' API. You can add multiple listeners if requires.

void addListener(MesiboListener listener);

addListener takes the following parameters:

listenerlistener object (of any type)

Remove Listener

Remove a listener previously added using addListener API.

void removeListener(MesiboListener listener);

removeListener takes the following parameters:

listenerlistener object (of any type)

Start Mesibo

Once you initialize, you can start Mesibo. Mesibo will start secure connection establishment with Mesibo cloud servers OR your on-premise Mesibo server. Note that, Mesibo will not establish a network connection till start API is called. However, once the start is called, Mesibo will automatically manage any future reconnections till stop() is called

void start();

start does not take any parameters.

Stop Mesibo

Disconnect any existing connection and also prevent future reconnections.|Void|

void stop();

stop does not take any parameters.

Initialization APIs Example

Below is an example of using initialization APIs.

Android Example

Mesibo api = Mesibo.getInstance();

// add listener

// set access token
if(0 != Mesibo.setAccessToken(accessToken) {
	return false;

// set database after setting access token so that it's associated with the user

// Now start mesibo
if(0 != Mesibo.start()) {
	return false;

iOS Example

In Swift



In Objective-C

[MesiboInstance addListener:self];

[MesiboInstance setAccessToken:accessToken];
[MesiboInstance setDatabase:@"mesibo.db"] ; 

[MesiboInstance start];

JavaScript Example

var api = new Mesibo();