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:

Initialize CometChat with the required information

- (void)initializeCometChat:(NSString *)siteUrl
                 licenseKey:(NSString *)licenseKey
                     apikey:(NSString *)apikey
            isCometOnDemand:(BOOL )isCometOnDemand
                    success:(void (^)(NSDictionary *response))success
                    failure:(void (^)(NSError *error))failure;

For Example:

[cometChat initializeCometChat:@"siteurl" licenseKey:@"licenceKey" apikey:@"apiKey" isCometOnDemand:NO 
        success:^(NSDictionary *response) {

        } failure:^(NSError *error) {

        }];

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.
isCometOnDemand – If you are using Cloud CometChat then ‘isCometOnDemand’ should be set as ‘Yes’ and for self hosted CometChat ‘isCometOnDemand’ should be set as ‘NO’
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.

Initialize CometChat with the required information

- (void)initializeCometChat:(NSString *)siteUrl
                 licenseKey:(NSString *)licenseKey
                     apikey:(NSString *)apikey
            isCometOnDemand:(BOOL )isCometOnDemand
                    success:(void (^)(NSDictionary *response))success
                    failure:(void (^)(NSError *error))failure;

For Example:

[cometChat initializeCometChat:@"siteurl" licenseKey:@"licenceKey" apikey:@"apiKey" isCometOnDemand:YES 
        success:^(NSDictionary *response) {

        } failure:^(NSError *error) {

        }];

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.
isCometOnDemand – If you are using Cloud CometChat then ‘isCometOnDemand’ should be set as ‘Yes’ and for self hosted CometChat ‘isCometOnDemand’ should be set as ‘NO’
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