question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Delay in reportNewIncomingCall triggering didDisplayIncomingCall

See original GitHub issue

Somewhat related to #107

When following the instructions in the README to adjust didReceiveIncomingPushWithPayload for iOS 13 changes, I’ve encountered a timing issue with how didDisplayIncomingCall is triggered.

In my VoipPushNotification handler for NewCall notifications I resolve the contact name before using RNCallKeep.displayIncomingCall().

With the new changes I am reporting the incoming call from the AppDelegate.m before sending the push notification to RNVoipPushNotificationManager.

Ideally I would update the newly reported call in the push notification handler with the contact name, but reportNewIncomingCall appears to trigger didDisplayIncomingCall after the push notification is handled even though it is run before the push notification is passed to RNVoipPushNotificationManager.

// Handle incoming pushes
- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type {
  // Process the received push
  NSLog(@"CVE PUSH VOIP push received: %@ %@", payload, type);

  NSDictionary* data = [payload.dictionaryPayload objectForKey:@"bsft"];
  NSString* pushType = [data objectForKey:@"type"];
  if ([pushType isEqualToString:@"NewCall"]) {
    NSString *uuid = [[[NSUUID UUID] UUIDString] lowercaseString];
    NSString *sender = [data objectForKey:@"sender"];
    [RNCallKeep reportNewIncomingCall:uuid handle:sender handleType:@"generic" hasVideo:false localizedCallerName:sender fromPushKit: YES];
  }

  [RNVoipPushNotificationManager didReceiveIncomingPushWithPayload:payload forType:(NSString *)type];
}

Logs showing order of events to didDisplayIncomingCall (RNCallKit received onIncomingCall is from the push notification handling):

2020-01-16 15:52:56.050306+0000 [622:80095] 'VoipPushNotification received notification', { message: 
   { bsft: 
      { ver: '2',
        type: 'NewCall',
        sdp: '...',
        registrationId: '...',
        privacy: 'false',
        callId: '...',
        callingNumber: '...',
        callTo: '...',
        'alert-type': 'audible',
        appearance: '...',
        sender: '...' } } }
2020-01-16 15:52:56.130603+0000 [622:80095] 'RNCallKit received onIncomingCall:', 'callUUID: 6e6d9195-43e5-4179-8c8c-6c9b97c33f84'
2020-01-16 15:52:56.135143+0000 [622:80095] 'RNCallKit received didDisplayIncomingCall:', 'callUUID: 224c8274-4851-4862-be2b-acc06ffb7157', 'fromPushKit: 1'
2020-01-16 15:52:56.374563+0000 [622:80095] 'RNCallKit received didDisplayIncomingCall:', 'callUUID: 6e6d9195-43e5-4179-8c8c-6c9b97c33f84', 'fromPushKit: 0'

My current workaround is to immediately end any call reported from PushKit (using the fromPushKit parameter) in didDisplayIncomingCall, but this is not very good user experience.

My other idea was to pass the callUUID from didReceiveIncomingPushWithPayload to RNVoipPushNotificationManager so that it could update the existing call instead of creating a new call, but I couldn’t find a way to pass additional paramaters.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
danjenkinscommented, Jan 16, 2020

@grit96 I ended up creating a UUID server side and send it in the push, and then I can pass that into callkit and then use it when the app loads from the Push. It feels like a giant mess with timings potentially broken etc etc, what about if your user accepts the call before the app is awake enough to do anything about it, what if the phone call was cancelled or answered elsewhere but your app is still loading up and so callkit is still “ringing”. Meh Apple.

0reactions
grit96commented, Jun 4, 2020

I would say so yes - my workaround was using a timer which seems to work okay.

Read more comments on GitHub >

github_iconTop Results From Across the Web

reportNewIncomingCall(with:update:completion:)
Reports a new incoming call with the specified unique identifier to the provider.
Read more >
reconnect-react-native-callkeep - npm
On Android when the application is in background, after a certain delay the OS will close every connection with informing about it.
Read more >
React Native CallKeep utilises a brand new iOS 10 framework ...
On Android when the application is in background, after a certain delay the OS will close every connection with informing about it.
Read more >
CallKit in iOS 13: How to delay ringing? - Stack Overflow
My VoIP app uses PJSIP. The incoming call scenario is: receive "Wakeup" push notification - this starts registering sip user and it takes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found