Skip to content
This repository has been archived by the owner on May 26, 2019. It is now read-only.

CallKit actions not always getting executed. #64

Open
henrikbjorn opened this issue Dec 7, 2018 · 9 comments
Open

CallKit actions not always getting executed. #64

henrikbjorn opened this issue Dec 7, 2018 · 9 comments

Comments

@henrikbjorn
Copy link

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.
@glocore
Copy link

glocore commented Dec 18, 2018

@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.

@henrikbjorn
Copy link
Author

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
Copy link
Author

We also found that this was important #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
Copy link
Author

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.

@glocore
Copy link

glocore commented Dec 21, 2018

@henrikbjorn thank you sir!

@henrikbjorn
Copy link
Author

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
Copy link
Author

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.

@LFSCamargo
Copy link

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

@henrikbjorn
Copy link
Author

@LFSCamargo #66 this one is important if you are reloading your app in development mode. Without this CallKit will be confused and nothing works correctly.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants