Note
Version 4 CometChat UI Kits
Weβve introduced a major update to CometChat UI kits. Version 4 features a modular architecture that gives you enhanced flexibility to build and customize your web and mobile apps. Visit our documentation to read more about this.
The UI Kit library is collection of custom UI Components and UI Screens design to build chat application within few minutes. UI kit is designed to avoid boilerplate code for building UI,it has three different ways to build a chat application with fully customizable UI. It will help developers to build a chat application within using various UI Components.
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 the 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:
sudo gem update cocoapods --pre
pod update
clean
build
NOTE: If you're building the new project, the please add below line in AppDelegate.swift
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
}
To install iOS UI Kit, you need to first register on CometChat Dashboard. Click here to sign up.
- Create a new app
- Head over to the Quick Start or API & Auth Keys section and note the
App ID
,Auth Key
, andRegion
.
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 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', '3.0.914'
pod 'CometChatCalls', '3.0.0'
end
________________________________________________________________
And then install the CometChatPro
framework through CocoaPods.
pod install
If you're facing any issues while installing pods then use below command.
pod install --repo-update
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 APP_ID with your CometChat appId
and region
with your app region in the above code.
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 setup 5 users for testing having UIDs:
SUPERHERO1
,SUPERHERO2
,SUPERHERO3
,SUPERHERO4
andSUPERHERO5
.
To integrate CometChat UIKit inside your app. Kindly follow the below steps:
i. Simply clone the UIKit Library from ios-chat-uikit repository.
ii. After cloning the repository, Navigate to Library
folder and drag and drop Library
folder inside your project's folder.
iii. Make sure you've selected β
Copy items if needed
as well as π Create groups
options while adding Library inside your project.
iv. If the Library is added sucessfully, all added folders will be in Yellow color.
CometChat UI is a way to launch a fully working chat application using the CometChat Kitchen Sink.In CometChat UI all the UI Components working together to give the full experience of a chat application with minimal coding effort.
To use CometChat UI 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.
CometChatUI
provides below method to present this activity:
-
setup(withStyle: .fullScreen)
: This will present the window in Full screen. -
setup(withStyle: .popover)
: This will present the window as a popover.
To receive real time call events, user has to register for them in App Delegate
class.
CometChatCallManager().registerForCalls(application: self)
Visit our Swift sample app repo to run the swift sample app.
Visit our Objective-C sample app repo to run the objective-c sample app.
-
To read the full dcoumentation on UI Kit integration visit our Documentation .
-
Facing any issues while integrating or installing the UI Kit please connect with us via real time support present in CometChat Dashboard..
Thanks to the following people who have contributed to this project:
@pushpsenairekar2911 π¨βπ»
@AbdullahAnsarri π¨βπ»
@ajayv-cometchat π¨βπ»
Contact us via real time support present in CometChat Dashboard.
This project uses the following license.