react-native-callkit icon indicating copy to clipboard operation
react-native-callkit copied to clipboard

CallKit actions not always getting executed.

Open henrikbjorn opened this issue 6 years ago • 9 comments

Hey, thanks for the package.

I am seeing a couple of different issues while using the library.

  • It seems that actions are not always fulfilled or called. Sometimes after CallKit.endCall the phone still thinks there is a call active and gets confused.
  • CallKit.displayIncomingCall often it will instantly flash the ui as an overlay and then show the app, and then show the actual overlay. This can also be seen by the many triggers of AppState changes.
  • AVAudioSession It is not clear to me how this works together with pjsip. Also it seems that the created audio session is not destroyed.
  • Trying to end a call after CallKit.displayIncomingCall sometimes does nothing. Even though the uuids are the same.

henrikbjorn avatar Dec 07 '18 09:12 henrikbjorn

@henrikbjorn were you able to figure this out? Are you using the react-native-pjsip library? I'm working on a SIP calling app that uses that library.

glocore avatar Dec 18 '18 11:12 glocore

Yeah we are using react-native-pjsip. We have cloned both packages and can be found at github.com/firmafon It contains some improvements that we found.

One of the things we found was that answering a call through CallKit needs to wait for didActivateAudioSession before actually answering the pjsip call. Otherwise it might fail to get control of the sound device.

henrikbjorn avatar Dec 18 '18 11:12 henrikbjorn

We also found that this was important https://github.com/ianlin/react-native-callkit/pull/66

On the first run from xcode it would work correctly, but on every subsequent reload of the device (via the debug menu) Callkit would be confused. This fixes this problem

henrikbjorn avatar Dec 18 '18 11:12 henrikbjorn

Also out react-native-pjsip fork uses promises instead of the callbacks. This makes it easier to handle for us. Since we use redux-saga and therefor want to wait on a promise until it is resolved.

henrikbjorn avatar Dec 18 '18 11:12 henrikbjorn

@henrikbjorn thank you sir!

glocore avatar Dec 21 '18 03:12 glocore

Another observation. When you are entering background you need to delete accounts which takes time. So you need to extend the background processing time by doing something like this:

- (void)applicationWillEnterForeground:(UIApplication *)application {
  [self endBackgroundTask];
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
  // Create a background task and deregister the pjsip registrations
  [self extendBackgroundRunningTime];
}

- (void)endBackgroundTask {
  if (self.backgroundUpdateTask != UIBackgroundTaskInvalid) {
    [[UIApplication sharedApplication] endBackgroundTask:self.backgroundUpdateTask];
    
    self.backgroundUpdateTask = UIBackgroundTaskInvalid;
  }
}

- (void)extendBackgroundRunningTime {
  if (self.backgroundUpdateTask != UIBackgroundTaskInvalid) {
    return;
  }
  
  self.backgroundUpdateTask = [[UIApplication sharedApplication] beginBackgroundTaskWithName:@"Unregistrations" expirationHandler:^{
    [self endBackgroundTask];
  }];
  
  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    [NSThread sleepForTimeInterval:5.0f];
    
    [[UIApplication sharedApplication] endBackgroundTask:self.backgroundUpdateTask];
    
    self.backgroundUpdateTask = UIBackgroundTaskInvalid;
  });
}

henrikbjorn avatar Dec 21 '18 09:12 henrikbjorn

When you receive a push notification from push kit, the app will not change state from background. So you need to register/create an account when that happens, if the user tries to answer the call via callkit.

henrikbjorn avatar Dec 21 '18 09:12 henrikbjorn

Here its not working also sometimes the endAllCalls function works but sometimes not

LFSCamargo avatar Jan 02 '19 22:01 LFSCamargo

@LFSCamargo https://github.com/ianlin/react-native-callkit/pull/66 this one is important if you are reloading your app in development mode. Without this CallKit will be confused and nothing works correctly.

henrikbjorn avatar Jan 03 '19 12:01 henrikbjorn