Initialization

This section provides you with the basic methods that need to be invoked to initialize CometChat. Please follow the steps below to get the initialization started.

Please select the product to know about the appropriate initialization steps.

Product:

Get the CometChat instance:

CometChat cometChat = CometChat.getInstance(context);

The parameter accepted by the getInstance() method is context of the activity or the application

Initialize CometChat with the required information

cometChat.initializeCometChat(siteUrl,licenseKey,apiKey,false,Callbacks callbacks)

For Example:

cometChat.initializeCometChat(siteURL, licenceKey, apiKey, false, new Callbacks() {
@Override
public void successCallback(JSONObject jsonObject) {

}

@Override
public void failCallback(JSONObject jsonObject) {

}
});

The parameters accepted by the initializeCometChat() method can be explained as follows:
siteUrl – This is the domain of your website.
licenceKey – This parameter is the product license key. You can find the license key in the CometChat members area.
apiKey – This is the api key. This can be found in the CometChat admin panel under the Settings -> Mobile tab.
callbacks – This is an instance of the Callback interface which contains the success and failure methods.This helps you to know if the initialization was successful.

Get the CometChat instance:

CometChat cometChat = CometChat.getInstance(context);

The parameter accepted by the getInstance() method is context of the activity or the application

Initialize CometChat with the required information

cometChat.initializeCometChat(siteUrl,licenseKey,apiKey,true,Callbacks callbacks)

For Example:

cometChat.initializeCometChat(siteURL, licenceKey, apiKey, true, new Callbacks() {
@Override
public void successCallback(JSONObject jsonObject) {

}

@Override
public void failCallback(JSONObject jsonObject) {

}
});

The parameters accepted by the initializeCometChat() method can be explained as follows:
siteUrl – This is the domain of your website.
licenceKey – This parameter is the product license key. You can find the license key in the CometChat members area.
apiKey – This is the api key. This can be found in the CometChat admin panel under the Settings -> Mobile tab.
callbacks – This is an instance of the Callback interface which contains the success and failure methods.This helps you to know if the initialization was successful.

  • Was this helpful?
  • Yes   No