react-native-callkit
react-native-callkit copied to clipboard
CallKit actions not always getting executed.
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.endCallthe phone still thinks there is a call active and gets confused. CallKit.displayIncomingCalloften 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 ofAppStatechanges.AVAudioSessionIt is not clear to me how this works together withpjsip. Also it seems that the created audio session is not destroyed.- Trying to end a call after
CallKit.displayIncomingCallsometimes does nothing. Even though the uuids are the same.
@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.
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.
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
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 thank you sir!
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;
});
}
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.
Here its not working also sometimes the endAllCalls function works but sometimes not
@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.