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:

In Android, Get the CometChat instance :

CCCometChat.getInstance(successcallback,failcallback);

**No need to call the getInstance Method in iOS

Initialize CometChat with the required information

In Android,

CCCometChat.initializeCometChat(siteUrl,licenseKey,apiKey,false,successcallback,failcallback);

In iOS,

CCCometChat.initializeCometChat(siteUrl,licenseKey,apiKey,"NO",successcallback,failcallback);

For Example:
In Android,

CCCometChat.initializeCometChat(siteURL, licenceKey, apiKey, false, successCallback(response){},failCallback(response){});

In iOS,

CCCometChat.initializeCometChat(siteURL, licenceKey, apiKey, "NO", successCallback(response){},failCallback(response){});

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.
successCallback – This is an instance of the Callback interface which contains the success methods.This helps you to know if the initialization was successful.
failCallback – This is an instance of the Callback interface which contains the failure methods.This helps you to know any error occurred during initialization.

In Android, Get the CometChat instance :

CCCometChat.getInstance(successcallback,failcallback);

**No need to call the getInstance Method in iOS

Initialize CometChat with the required information

In Android,

CCCometChat.initializeCometChat(siteUrl,licenseKey,apiKey,false,successcallback,failcallback);

In iOS,

CCCometChat.initializeCometChat(siteUrl,licenseKey,apiKey,"NO",successcallback,failcallback);

For Example:
In Android,

CCCometChat.initializeCometChat(siteURL, licenceKey, apiKey, false, successCallback(response){},failCallback(response){});

In iOS,

CCCometChat.initializeCometChat(siteURL, licenceKey, apiKey, "NO", successCallback(response){},failCallback(response){});

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.
successCallback – This is an instance of the Callback interface which contains the success methods.This helps you to know if the initialization was successful.
failCallback – This is an instance of the Callback interface which contains the failure methods.This helps you to know any error occurred during initialization.

  • Was this helpful?
  • Yes   No