Handle UUID case sensitivity in CallKeep v3+
mastersetCurrentCallActive, endCall, or startCall.repository·master·Indexed 21 days ago
https://github.com/react-native-webrtc/react-native-callkeepA React Native bridge to iOS CallKit and Android ConnectionService Framework. It allows VoIP developers to integrate calls into the system's native calling UI, manage call states, and handle call lifecycle events such as answering, ending, and muting calls. Supports Android Self Managed mode for custom in-call UIs and requires real devices for testing as it does not work on simulators.
setCurrentCallActive, endCall, or startCall.Self Managed mode allows your app to provide its own UI for managing calls (in-call UI and incoming call notifications). This is an 'all or nothing' approach.
Implementation Steps:
selfManaged: true in the setup options.<uses-permission android:name="android.permission.READ_CALL_LOG" /> to your android/src/main/AndroidManifest.xml.RNCallKeep.displayIncomingCall from React Native.showIncomingCallUi event. When fired, you must show a high-priority incoming call UI (e.g., a high-priority notification).answerCall or endCall via RNCallKeep.createIncomingConnectionFailed event will fire; you should then reject the incoming SIP Invite.Best Practices:
setup options.<!-- Required for Self Managed mode in android/src/main/AndroidManifest.xml -->
<uses-permission android:name="android.permission.READ_CALL_LOG" />On iOS, if a user interacts with a call (answers or ends it) while the app is in a killed state (before the JS bridge is initialized), those actions are lost unless you use didLoadWithEvents.
This event acts as a cache that propagates native events that occurred before the JS context was ready. To use this reliably, you must perform setup in your AppDelegate.m.
Note: This is a helper for early events; you must still subscribe to all other standard events normally.
// Register this early in your app
RNCallKeep.addEventListener('didLoadWithEvents', (events) => {
// events is an Array of objects:
// { name: string, data: object }
// Example: { name: 'RNCallKeepPerformAnswerCallAction', data: { callUUID: '...' } }
events.forEach(event => {
// handle or ignore based on app logic
});
});When using RNCallKeepBackgroundMessagingService to wake up a killed application, you must register a headless task in your index.android.js file to handle the incoming background message. The task receives an object containing name, callUUID, and handle.
// index.android.js
AppRegistry.registerHeadlessTask('RNCallKeepBackgroundMessage', () => ({ name, callUUID, handle }) => {
// Make your call here
return Promise.resolve();
});Since iOS 13, you must report incoming calls that wake up your application via a VoIP push. In your AppDelegate.m, use RNCallKeep.reportNewIncomingCall within the didReceiveIncomingPushWithPayload method to register the call with the system.
- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type withCompletionHandler:(void (^)(void))completion {
// Process the received push
[RNVoipPushNotificationManager didReceiveIncomingPushWithPayload:payload forType:(NSString *)type];
// Retrieve information like handle and callerName here
// NSString *uuid = ...
// NSString *callerName = ...
// NSDictionary *extra = ...
[RNCallKeep reportNewIncomingCall: uuid
handle: handle
handleType: @"generic"
hasVideo: NO
localizedCallerName: callerName
supportsHolding: YES
supportsDTMF: YES
supportsGrouping: YES
supportsUngrouping: YES
fromPushKit: YES
payload: extra
withCompletionHandler: completion];
}Since Android 11, accessing the microphone in the background requires starting a foreground service.
compileSdkVersion to 30 or higher.foregroundService key in the setup() method.foregroundServiceType in your AndroidManifest file.Install the library using npm or yarn:
npm install --save react-native-callkeep
# or
yarn add react-native-callkeepNote that CallKit (iOS) and ConnectionService (Android) are only available on real devices; the library will not work on simulators.
npm install --save react-native-callkeepAfter adding the library, you must perform these additional configuration steps to ensure the library functions correctly:
In Xcode, under Build Phases > Link Binary With Libraries, add the following frameworks and mark them as Optional:
CallKit.frameworkIntents.frameworkIn Xcode, go to the Build Settings tab, search for Header Search Paths, and add:
$(SRCROOT)/../node_modules/react-native-callkeep/ios/RNCallKeep
To allow the app to handle calls in the background, add the voip string to the UIBackgroundModes key in your Info.plist file.
<key>UIBackgroundModes</key>
<array>
<string>voip</string>
</array>To wake up your application to display an incoming call when it is killed or in the background, you must use push notifications:
To set up and run the provided example project, follow these steps:
yarn install in the root directory, then navigate to the ios folder and run pod install.yarn start to launch the bundler.yarn android or yarn ios to build and run the app on your device or emulator.# Install dependencies
yarn install
cd ios
pod install
# Start metro bundler
yarn start
# Start the application
yarn android # or yarn iosreact-native-callkeep with Expo, you must create a development build. Expo Go does not support custom native modules. You can test the library on physical iOS and Android devices using a development build.If your React Native project supports automatic linking, run the following command to link the library:
react-native link react-native-callkeep