I want to integrate with my app
- Get your application keys
- Add the CometChat dependency
- Initialize CometChat
- Register or Login your user
- Integrate our UI Kits
I want to explore iOS sample apps.
Import the app into Xcode and follow the steps mentioned in theREADME.md file.
Download Swift Chat App
Download Obj-c Chat App
Download iOS SDK from Github
Get your Application Keys
Signup for CometChat and then:- Create a new app
- Head over to the API & Auth Keys section and note the Auth Key, App ID & Region
Add the CometChat Dependency
CocoaPods
We recommend using CocoaPods, as they are the most advanced way of managing iOS project dependencies. Open a terminal window, move to your project directory, and then create aPodfile by running the following command.
- Swift
- Swift
v2.4.1+ onwards, Voice & Video Calling functionality has been moved to a separate framework. In case you do not plan to use the calling feature, please add the Calling framework
pod 'CometChatCalls', '2.1.1' in your app Podfile.CometChatPro framework through CocoaPods.
- Swift
- Swift
CometChatPro by command.
- Swift
Setup Bitcode
You can set the Enable Bitcode setting to YES present in build settings in your XCode project.
Swift Standard Libraries
CometChatProframework build on Swift, you have to ensure the required libraries are embedded. This can be done by setting the “Always Embed Swift Standard Libraries” checkbox in your target’s build settings to “Yes”:

Set Header Search Path
Set theHeader Search Paths to $SDKROOT/usr/include/libxml2.

Excluded Architecture
Setting for build for active architecture

Initialize CometChat
Theinit() method initializes the settings required for CometChat. We suggest you call the method on app startup preferably in the didFinishLaunchingWithOptions: method of the AppDelegate class.
- Swift
- Objective C
appId with your CometChat App ID in the above code.
Register and Login your User
Once initialization is successful, you will need to create a user. To create users on the fly, you can use thecreateUser() method. This method takes a User object and the API Key as input parameters and returns the created User object if the request is successful.
- Swift
login() method.
The login method needs to be called in the following scenarios:
- When the user is logging to the App for the first time.
- If the
CometChat.getLoggedInUser()function returns nil.
- Swift
- Objective C
AUTH_KEY with your CometChat AuthKey in the above code.
Sample UsersWe have set up 5 users for testing having UIDs:
cometchat-uid-1, cometchat-uid-2, cometchat-uid-3, cometchat-uid-4 and cometchat-uid-5.login() method returns the User object containing all the information of the logged in user.