react-native-webrtc / react-native-callkeep

iOS CallKit framework and Android ConnectionService for React Native
ISC License
884 stars 431 forks source link

React-Native - Enable to create call when using CallKeep in React-Native use npm install react-native-callkeep - (App crash when I init call) #354

Open viv578ek opened 3 years ago

viv578ek commented 3 years ago

I have setup CallKeep in react native

Import RNCallKeep
**import RNCallKeep from "react-native-callkeep";**

**Init setup CallKeep**
RNCallKeep.setup(options).then(accepted => {});

**When I make a Outgoing Call using start call** 
RNCallKeep.startCall(uuid, number, number, generic, false); 

**I am also add Libraries** 
 -> project -> Target -> Frameworks, Libraries and Embedded Content and Add CallKit.frameworks

**AppDelegate.m added some function**
#import "RNCallKeep.h"

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray * __nullable restorableObjects))restorationHandler
{
 return [RNCallKeep application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
}      

 **When I start a call App crashed main.m iOS file** 
 #import <UIKit/UIKit.h>
 #import "AppDelegate.h"

 int main(int argc, char * argv[]) {
@autoreleasepool {
   return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
  }
 }

**App Crash Line main.m
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));**

Getting thread : 
2021-01-27 16:07:43.128862+0530 Signal_Wire[893:52417] [RNCallKeep][requestTransaction] Requested transaction successfully
2021-01-27 16:07:43.172469+0530 Signal_Wire[893:51815] [RNCallKeep][CXProviderDelegate][provider:performStartCallAction]
2021-01-27 16:07:43.172584+0530 Signal_Wire[893:51815] [RNCallKeep][configureAudioSession] Activating audio session
2021-01-27 16:07:43.561084+0530 Signal_Wire[893:51815] [RNCallKeep][CXProviderDelegate][provider:didActivateAudioSession]
2021-01-27 16:07:43.561184+0530 Signal_Wire[893:51815] [RNCallKeep][configureAudioSession] Activating audio session
2021-01-27 16:07:43.626132+0530 Signal_Wire[893:51815] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[1]'
*** First throw call stack:`enter code here`
(0x1843359d8 0x19869eb54 0x18439fd98 0x1843ab1f4 0x1842308a8 0x184223c04 0x1054bf674 0x1054c4e4c 0x1a252ec70 0x10b9dbce4 0x10b9dd528 0x10b9eb994 0x1842b55e0 0x1842afa88 0x1842aeba0 0x19afec598 0x186b9e3d8 0x186ba3958 0x104fb5818 0x183f8d568)
libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[1]'
terminating with uncaught exception of type NSException

**But caller Number recored show in Native call List**
**please help me if any have idea related this issues.**

Description

Steps to Reproduce

Versions

- Callkeep:
- React Native:
- iOS:
- Android:
- Phone model: 

Logs

Paste here
martin-juul commented 3 years ago

It's because you need to activate the audio session in your sip/webrtc library. If you use any variation of react-native-sip-pjsip - then you do it like this:

const endpoint = new Endpoint();
await endpoint.start()

    RNCallKeep.addEventListener('didActivateAudioSession', () => {
      endpoint.activateAudioSession()
    })

    RNCallKeep.addEventListener('didReceiveStartCallAction', () => {
      endpoint.deactivateAudioSession()
    })

Otherwise the client don't know when/if an audio session should start/stop. On iOS, CallKit ensures the call is given priority. But if you never say when the session should start, it will crash your app.