CometChat Pro Documentation

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

iOS UI Kit

Learn a quick integration of text chat and voice/video calling features for your application

CometChat iOS UI Kit is a collection of custom UI Components designed to build text chat and voice/video calling features in your application.
The UI Kit is developed to keep developers in mind and aims to reduce development efforts significantly.

The UI Kit’s customizable UI components simplify the process of integrating text chat and voice/video calling features to your website or mobile application in a few minutes.

I want to checkout iOS UI Kit.

Follow the steps mentioned in the README.md file.

Kindly, click on below button to download our iOS Chat UI Kit.

iOS Chat UI Kit

View on Github


I want to integrate UI Kit with my App

  1. UI Components
  2. Customize UI Kit

I want to explore sample apps.

Import the app into Xcode and follow the steps mentioned in the README.md file.

Kindly, click on below button to download our Swift Sample App.

Swift Sample App

View on Github

Or else, you can also checkout our Objective-C Sample App.

Objective-C Sample App

View on Github


Installation Steps

Prerequisites

Before you begin, ensure you have met the following requirements:

  • You have installed the latest version of Xcode. (Above Xcode 12 Recommended)
  • iOS Chat UI Kit works for iOS devices from iOS 11 and above.

🚧

Note

Please install the latest pod version on your Mac to avoid integration issues

Please follow the below steps:

  1. sudo gem update cocoapods --pre
  2. pod update
  3. clean
  4. build

🚧

Note

If you're building the new project, the please add below line in AppDelegate.swift

var window: UIWindow?


Installing iOS Chat UI Kit

1. Setup πŸ”§

To install iOS UI Kit, you need to first register on CometChat Dashboard. Click here to sign up.

i. Get Your Application Keys πŸ”‘

  • Create a new app
  • Head over to the QuickStart or API & Auth Keys section and note the App ID, Auth Key, and Region.

ii. Add the CometChat Dependency

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 a Podfile by running the following command

Create podfile using the below command.

$ pod init

Add the following lines to the Podfile.

For Xcode 12 and above:

platform :ios, '11.0'
use_frameworks!

target 'YourApp' do
     pod 'CometChatPro', '2.3.7'
end

And then install the CometChatPro framework through CocoaPods.

pod install

If you're facing any issues while installing pods then use the below command.

pod install --repo-update

2. Configure CometChat inside your app

i. Initialize CometChat

The init() method initializes the settings required for CometChat. We suggest calling the init() method on app startup, preferably in the didFinishLaunchingWithOptions() method of the Application class.

import CometChatPro

class AppDelegate: UIResponder, UIApplicationDelegate{

   var window: UIWindow?
   let appId: String = "ENTER APP ID"
   let region: String = "ENTER REGION CODE"
    
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

  let mySettings = AppSettings.AppSettingsBuilder().subscribePresenceForAllUsers().setRegion(region: region).build()
  CometChat(appId: appId ,appSettings: mySettings,onSuccess: { (isSuccess) in
  
                print("CometChat Pro SDK intialise successfully.")

        }) { (error) in
            print("CometChat Pro SDK failed intialise with error: \(error.errorDescription)")
        }
        return true
    }
}

🚧

Note:

Make sure you replace the appId with your CometChat appId and region with your app region in the above code.

ii. Log in your User

The login() method returns the User object containing all the information of the logged-in user.

let uid    = "SUPERHERO1"
let authKey = "ENTER AUTH KEY"

CometChat.login(UID: uid, apiKey: authKey, onSuccess: { (user) in

  print("Login successful: " + user.stringValue())

}) { (error) in

  print("Login failed with error: " + error.errorDescription);

}

🚧

Note :

  • Make sure you replace the authKey with your CometChat Auth Key in the above code.
  • We have set up 5 users for testing having UIDs: SUPERHERO1, SUPERHERO2, SUPERHERO3, SUPERHERO4, and SUPERHERO5.

3. Add UI Kit to your project

To integrate CometChat UIKit inside your app. Kindly follow the below steps:

i. Simply clone the UIKit Library from the ios-chat-uikit repository.

ii. After cloning the repository, Navigate to the Library folder and drag and drop the Library folder inside your project's folder.

iii. Make sure you've selected βœ… Copy items if needed as well as πŸ”˜ Create group options while adding a `Library inside your project.

iv. If the Library is added successfully, all added folders will be in Yellow color.


4. Launch CometChat

CometChatUI is an option to launch a fully functional chat application using the UI Kit. In UI Kit all the UI Components are interlinked and work together to launch a fully functional chat on your website/application.

To use CometChatUI user has to launch CometChatUI class. CometChatUI is a subclass of UITabbarController.

DispatchQueue.main.async {
let cometChatUI = CometChatUI()
cometChatUI.setup(withStyle: .fullScreen)
self.present(cometChatUI, animated: true, completion: nil)
}

🚧

Note

Please run the above code snippet in the main thread.

To receive real-time call events, the user has to register for them in the App Delegate class.

CometChatCallManager().registerForCalls(application: self)

Updated 27 days ago



iOS UI Kit


Learn a quick integration of text chat and voice/video calling features for your application

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.