CometChat Developer Documentation

Welcome Ninja!

You'll find comprehensive guides and documentation to help you start working with CometChat as quickly as possible. Let's jump right in!

Get Started    

To add CometChat to your iOS app, please perform the following steps

Add Dependencies Manually:

Click on Targets → Your app name → and then the ‘Build Phases’ tab.
Expand ‘Link Binary With Libraries’ as given below and add the following frameworks.

  1. SystemConfiguration.framework
  2. MobileCoreServices.framework
  3. CoreGraphics.framework
  4. CFNetwork.framework
  5. libxml2.tbd
  6. libz.tbd
  7. libsqlite3.tbd

Add Dependencies Using CocoaPods:

Please add the below lines to your project's Podfile

pod 'MessageSDKFramework' 
pod 'cometchat-ui' 
pod ‘Firebase/Auth’
pod ‘Firebase/Database’
pod ‘Firebase/Messaging’

Cocoapods setup

If you want to know about CocoaPods usage and installation you can refer to link below:
https://guides.cocoapods.org/using/using-cocoapods
Also, please make sure you are using the latest version of Cocoapods.

Add Linker Flag:

Click on Targets → Your app name → and then the ‘Build Settings’ tab.
Scroll down to the ‘Linking’ section, and double-click to the right of where it says ‘Other Linker Flags’. Click on the “+” button to add the following:

  1. -ObjC

Bitcode Settings:

Click on Targets → Your app name → and then the ‘Build Settings’ tab.
Scroll down to the 'Build Options' section, and set the value of 'Enable Bitcode' to 'NO'.

Additional Setup for Swift

In order for Xcode to use an Objective-C based framework in Swift, it needs to have a bridging header file. We have included a bridging header file in our framework. To link to it, you must open the build settings for your new target, and search for the Objective-C Bridging Header setting. You must then provide the path to the CometChat-Bridging-Header.h.

The path should be something similar to the one shown below :
$(SRCROOT)/Pods/cometchat-ui/cometchat-ui/cometchat-ui.framework/Versions/A/Headers/CometChat-Bridging-Header.h

Initialize the SDK

Initialization binds the SDK to your app and syncs the various basic parameters required for the CometChat SDK to function.

let cometChat : CometChat = CometChat();
let licenseKey: String = "COMETCHAT-XXXXX-XXXXX-XXXXX-XXXXX";
let apiKey: String= "xxxxxxxxxxxxxxxxxxxxxx";

self.cometChat.initializeCometChat("", licenseKey:licenseKey, apikey:apiKey, isCometOnDemand:true, 
 
 				success: {(response) in
       
            
        },failure:{(error) in
            

        })
CometChat *cometChat = [[CometChat alloc]init];
NSString* licenseKey = @"COMETCHAT-XXXXX-XXXXX-XXXXX-XXXXX";
NSSTring* apiKey = @"xxxxxxxxxxxxxxxxxxxxxx";

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

        } failure:^(NSError *error) {

        }];