Giter VIP home page Giter VIP logo

Comments (17)

chevonc avatar chevonc commented on June 13, 2024 7

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

from react-native-voip-push-notification.

vsalle avatar vsalle commented on June 13, 2024 5

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

from react-native-voip-push-notification.

VSPL avatar VSPL commented on June 13, 2024 3

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.

from react-native-voip-push-notification.

Phineas avatar Phineas commented on June 13, 2024 3

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

from react-native-voip-push-notification.

naderjavid avatar naderjavid commented on June 13, 2024 1

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

from react-native-voip-push-notification.

aminosman avatar aminosman commented on June 13, 2024

Are you able to test on real device running any other version of iOS?

from react-native-voip-push-notification.

JJMoon avatar JJMoon commented on June 13, 2024

I had same problem. It is because when the app is terminated, when the notification comes the JS part is not ready.
You can fire the event with 1 second delay as follows in the iOS code.

- (void)handleRemoteNotificationReceived:(NSNotification *)notification
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    [_bridge.eventDispatcher sendDeviceEventWithName:@"voipRemoteNotificationReceived"
                                                body:notification.userInfo];
});
}

from react-native-voip-push-notification.

hoanganhnh2009 avatar hoanganhnh2009 commented on June 13, 2024

I had same problem. It is because when the app is terminated, when the notification comes the JS part is not ready.
You can fire the event with 1 second delay as follows in the iOS code.

- (void)handleRemoteNotificationReceived:(NSNotification *)notification
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    [_bridge.eventDispatcher sendDeviceEventWithName:@"voipRemoteNotificationReceived"
                                                body:notification.userInfo];
});
}

Thanks for you.

from react-native-voip-push-notification.

danj565 avatar danj565 commented on June 13, 2024

I am having the exact same issue. I tried @JJMoon 's suggestion but did not work (Thank you for the suggestion tho!). I also tried the initialiationCompleted as linked by @JJMoon which didn't work either.

2.1.0 / IPhone X / RN 0.62.2 / iOS 13.5.1 / XCode 11.5

@aminosman @vsalle - Did you find a solution?

Thank you!

from react-native-voip-push-notification.

danj565 avatar danj565 commented on June 13, 2024

I discovered the issue: https://stackoverflow.com/questions/58115125/ios-13-not-getting-voip-push-notifications-in-background

from react-native-voip-push-notification.

adrian1388 avatar adrian1388 commented on June 13, 2024

I am running into this issue in the part that JS is not running but not what @danj565 says, because I can see correct logs on didReceiveIncomingPushWithPayload on AppDelegate.

I tried @JJMoon answer but I have a problem with _bridge variable: "Use of undeclared identifier '_bridge'"

- (void)handleRemoteNotificationReceived:(NSNotification *)notification
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    [_bridge.eventDispatcher sendDeviceEventWithName:@"voipRemoteNotificationReceived"
                                                body:notification.userInfo];
});
}

@JJMoon , could you please, explain me if this code is only available with your copy of the project? Sorry, My Objective C knowledge is not the best. How can I get _bridge variable?

from react-native-voip-push-notification.

acro5piano avatar acro5piano commented on June 13, 2024

I had the same issue but (maybe) thanks to @chevonc it was fixed.

from react-native-voip-push-notification.

naderjavid avatar naderjavid commented on June 13, 2024

thanks every body!
i did every step but still doesn't work in background

AppDelegate.txt

this is my AppDelegate file
please help.

from react-native-voip-push-notification.

acro5piano avatar acro5piano commented on June 13, 2024

@naderjavid I think you should try first a very simple example like the following code. 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];
}

from react-native-voip-push-notification.

Andriiklymiuk avatar Andriiklymiuk commented on June 13, 2024

has somebody have found viable solution? have kind of same issue (addEventListener('notification') not called in background/terminated. Help?)

from react-native-voip-push-notification.

acro5piano avatar acro5piano commented on June 13, 2024

@Andriiklymiuk in my case it doesn't work in the background state. Instead I decided to handle things in JS land(not in the native land). Now sure it works perfectly but it meets my need.

from react-native-voip-push-notification.

zxcpoiu avatar zxcpoiu commented on June 13, 2024

please test the fix in PR #69

from react-native-voip-push-notification.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.