react-native-voip-push-notification: didReceiveIncomingPushWithPayload not called in background/terminated

Everything works fine when app is running in foreground, method gets called and call screen shows. If I minimize the app though nothing gets called and nothing gets logged even. I have read over the readme a million times and followed every step.

Read this: https://developer.apple.com/library/ios/documentation/Performance/Conceptual/EnergyGuide-iOS/OptimizeVoIP.html

Added this: Background Modes -> Voice over IP

Any thoughts? Running iOS 13.4.1 on iPhone XR w/ RN 0.61.5

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 17 (1 by maintainers)

Commits related to this issue

Most upvoted comments

For those still hitting this issue, you can ensure the terminated app receives the native voice notif by calling voipRegistration in your AppDelegate.m as early as possible, inside didFnishLaunchingWithOptions. I do it here after right after the bridge is initialized:

  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  
  // register for voip notifs immediately to recv. notifs when app is killed - doing this from the JS side is too slow
  RNVoipPushNotificationManager* voipModule = [bridge moduleForClass:[RNVoipPushNotificationManager class]];
  [voipModule voipRegistration];
  
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"AppName"
                                            initialProperties:nil];

This will call cause didReceiveIncomingPushWithPayload to properly be called on the native side when the app is terminated.

Be sure to remove any duplicated call to the JS equivalent of voipRegistration so two delegates aren’t registered

Everything works fine when app is running in foreground, method gets called and call screen shows. If I minimize the app though nothing gets called and nothing gets logged even. I have read over the readme a million times and followed every step.

Read this: https://developer.apple.com/library/ios/documentation/Performance/Conceptual/EnergyGuide-iOS/OptimizeVoIP.html

Added this: Background Modes -> Voice over IP

Any thoughts? Running iOS 13.4.1 on iPhone XR w/ RN 0.61.5

Same behavior on my side

iPhone X on iOS 13.4.1 with RN 0.62.2

@chevonc Tried adding this at same place you did to no avail, unfortunately. Still works when app is in foreground state though.

UPDATE: It does actually work! I had to reinstall the app - the iOS system decides to terminate your app instantly if you fail to report to CallKit too many times, which I did during development and testing.

I am also having same issue, read a lot but not finding solution. We have implemented this solution https://github.com/nimbleape/react-native-callkeep along with this solution. Our iOS scenario,

In Foreground, Working fine

In Background, Not Working

In Killed State, Not Working

Please help.

@naderjavid I think you should try first a very simple example like this. I got a call after I removed some extra code.

// --- Handle incoming pushes (for ios >= 11)
- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type withCompletionHandler:(void (^)(void))completion {
  NSString *uuid = @"44713e33-fa78-4ff5-8ec5-983e0832d1c6";
  NSString *callerName = @"Test";
  NSString *handle = @"handle";
  [RNCallKeep reportNewIncomingCall:uuid handle:handle handleType:@"generic" hasVideo:false localizedCallerName:callerName fromPushKit: YES payload:nil];
}

thank you @acro5piano my problem is solved!