This guide walks you through installing the CometChat Calls SDK and configuring it in your React Native application.
Add the CometChat Dependency
Using npm
npm install @cometchat/calls-sdk-react-native
Using Yarn
yarn add @cometchat/calls-sdk-react-native
iOS Configuration
Install CocoaPods Dependencies
Navigate to your iOS directory and install the pods:
Add Permissions
Add the required permissions to your ios/YourApp/Info.plist:
<key>NSCameraUsageDescription</key>
<string>Camera access is required for video calls</string>
<key>NSMicrophoneUsageDescription</key>
<string>Microphone access is required for voice and video calls</string>
Enable Background Modes
For calls to continue when the app is in the background:
- Open your project in Xcode
- Select your target and go to Signing & Capabilities
- Click + Capability and add Background Modes
- Enable:
- Audio, AirPlay, and Picture in Picture
- Voice over IP (if using VoIP push notifications)
Android Configuration
Add Repository
Add the CometChat repository to your project level android/build.gradle:
allprojects {
repositories {
google()
mavenCentral()
maven {
url "https://dl.cloudsmith.io/public/cometchat/cometchat/maven/"
}
}
}
Add Java 8 compatibility to your app level android/app/build.gradle:
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
Add Permissions
Add the required permissions to your android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
For Android 6.0 (API level 23) and above, you must request camera and microphone permissions at runtime before starting a call.
Request Runtime Permissions
Use a library like react-native-permissions or implement native permission requests:
import { PermissionsAndroid, Platform } from 'react-native';
async function requestCallPermissions(): Promise<boolean> {
if (Platform.OS === 'android') {
const granted = await PermissionsAndroid.requestMultiple([
PermissionsAndroid.PERMISSIONS.CAMERA,
PermissionsAndroid.PERMISSIONS.RECORD_AUDIO,
]);
return (
granted['android.permission.CAMERA'] === PermissionsAndroid.RESULTS.GRANTED &&
granted['android.permission.RECORD_AUDIO'] === PermissionsAndroid.RESULTS.GRANTED
);
}
return true;
}
Verify Installation
After installation, rebuild your app:
# iOS
npx react-native run-ios
# Android
npx react-native run-android