Comments (17)
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.
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.
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.
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.
@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 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.
Are you able to test on real device running any other version of iOS?
from react-native-voip-push-notification.
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.
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.
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.
I discovered the issue: https://stackoverflow.com/questions/58115125/ios-13-not-getting-voip-push-notifications-in-background
from react-native-voip-push-notification.
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.
I had the same issue but (maybe) thanks to @chevonc it was fixed.
from react-native-voip-push-notification.
thanks every body!
i did every step but still doesn't work in background
this is my AppDelegate file
please help.
from react-native-voip-push-notification.
@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.
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.
@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.
please test the fix in PR #69
from react-native-voip-push-notification.
Related Issues (20)
- App crashes when i receive a VOIP notification when a call is cancelled. HOT 2
- delete this.
- No notification was received when the app entered the "Killed" state. HOT 4
- Integrating with Expo HOT 12
- App kill, bundle is made but no event or RNCallKeep run HOT 3
- VoipPushNotification.addEventListener('notification', () => {}); call twice HOT 12
- TypeError: Cannot read property 'registerVoipToken' of null
- TypeError: Cannot read property 'wakeupByPush' of undefined
- Production/Staging Token HOT 1
- Sometimes Incoming Call UI does not display in background: Voip Push Dropped On Floor HOT 13
- _delayedEvents multiple initialisation HOT 1
- Unable to send Notification HOT 2
- Why is `didInvalidatePushTokenForType` event not listenable on the js ?
- Auto Linking is not working HOT 1
- No known class method for selector 'reportNewIncomingCall' HOT 2
- EAS Build HOT 1
- error run: Expected a type HOT 4
- read "payload" in JS HOT 1
- unrecognized selector sent to instance HOT 3
- Ringing after logout HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-voip-push-notification.