AI Integration Quick Reference
AI Integration Quick Reference
Prerequisites
| Requirement | Version |
|---|---|
| Xcode | 12 or above |
| iOS | 11 or higher |
- App ID
- Region
- Auth Key (for development)
Installation
CocoaPods
Create aPodfile in your project directory:
Swift Package Manager
- Open Xcode, go to the project’s General settings tab and select the project under Project in the left column.
- Go to the Swift packages tab and click on the + button.

- Enter the repository URL
https://github.com/cometchat/chat-sdk-ios.git, set dependency rule toUp to Next Major Versionwith version4.1.0, and click Add Package.

- Ensure
CometChatSDKis checked in the Package Product column and click Add Package.

Request Authorization
Add justification strings to your app’sInfo.plist for camera, microphone, and photo library access:

Setup Bitcode
Set Enable Bitcode toYES in your target’s build settings.

Swift Standard Libraries
Set"Always Embed Swift Standard Libraries" to Yes in your target’s build settings:

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

Initialization
Theinit() method initializes the SDK and must be called before any other CometChat method. Call it once at app startup, typically in didFinishLaunchingWithOptions: of your AppDelegate.
- Swift
- Objective-C
APP_ID and APP_REGION with your credentials from the Dashboard.
Parameters
| Parameter | Type | Description |
|---|---|---|
| appId | String | Your CometChat App ID |
| appSettings | AppSettings | Configuration object built with AppSettingsBuilder |
AppSettings Options
| Method | Description | Default |
|---|---|---|
setRegion(region:) | Region where your app was created (us, eu, in) | Required |
subscribePresenceForAllUsers() | Subscribe to presence events for all users | — |
subscribePresenceForRoles(roles:) | Subscribe to presence for specific roles | — |
subscribePresenceForFriends() | Subscribe to presence for friends only | — |
autoEstablishSocketConnection(_:) | Let SDK manage WebSocket connections | true |
overrideAdminHost(adminHost:) | Custom admin URL (dedicated deployment) | — |
overrideClientHost(clientHost:) | Custom client URL (dedicated deployment) | — |
Presence Subscription
Choose how to subscribe to user presence (online/offline status):WebSocket Connection
By default, the SDK manages WebSocket connections automatically. To manage them manually:Next Steps
Authentication
Log in users with Auth Key or Auth Token
Send Messages
Send your first message