Auth Key is for development/testing only. In production, generate Auth Tokens on your server using the REST API. Never expose Auth Keys in production client code.
Add justification strings to your app’s Info.plist for camera, microphone, and photo library access:
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict><key>NSCameraUsageDescription</key> <string>$(PRODUCT_NAME) need access to the camera in order to update your avatar</string><key>NSPhotoLibraryUsageDescription</key> <string>$(PRODUCT_NAME) need access to the Photo Library in order to send Media Messages</string><key>NSMicrophoneUsageDescription</key> <string>$(PRODUCT_NAME) need access to the Microphone in order to connect Audio/Video call</string>
The init() 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
import CometChatSDKclass AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? let appId: String = "APP_ID" let region: String = "APP_REGION" func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { let mySettings = AppSettings.AppSettingsBuilder() .subscribePresenceForAllUsers() .setRegion(region: region) .autoEstablishSocketConnection(true) .build() CometChat.init(appId: appId, appSettings: mySettings, onSuccess: { (isSuccess) in if (isSuccess) { print("CometChat SDK initialized successfully.") } }) { (error) in print("CometChat SDK failed to initialize with error: \(error.errorDescription)") } return true }}