onNotificationReceivedForeground not work when push remote notifications, but use localNotification is work, when I comment [RNNotificationsBridgeQueue sharedInstance].jsIsReady == YES remote notifications is trigger onNotificationReceivedForeground
RN: 0.42
react-native-notifications: 1.1.15
iOS: 10.3.3
Indeed, I am facing the same issue
Why do we need the check for [RNNotificationsBridgeQueue sharedInstance].jsIsReady anyway?
Additionally to my knowledge the JS thread is never running when app is background state, so the onNotificationReceivedBackground event can't actually be received..
funny thing, i used NotificationsIOS.consumeBackgroundQueue() after requesting for permission, but it didn't work.
then i headed to xcode and started checking the codes at RNNotifications.m, i figured jsIsReady == YES is not working acordingly.
so far it's boring but funny thing is when i refactored the code to this:
+ (void)didReceiveRemoteNotification:(NSDictionary *)notification
{
UIApplicationState state = [UIApplication sharedApplication].applicationState;
RNNotificationsBridgeQueue* notificationBridgeQueue = [RNNotificationsBridgeQueue sharedInstance];
if (notificationBridgeQueue.jsIsReady == YES) {
// JS thread is ready, push the notification to the bridge
if (state == UIApplicationStateActive) {
// Notification received foreground
[self didReceiveNotificationOnForegroundState:notification];
} else if (state == UIApplicationStateInactive) {
// Notification opened
[self didNotificationOpen:notification];
} else {
// Notification received background
[self didReceiveNotificationOnBackgroundState:notification];
}
} else {
// JS thread is not ready - store it in the native notifications queue
[[RNNotificationsBridgeQueue sharedInstance] postNotification:notification];
}
}
now it works perfectly.
i'm not a really good objective-c developer but i don't get why it now it works, practicly codes are the same. any comment on this issue?
@lidanh @denissb @FuYaoDe
could you please check this and see if it works on your codes as well?
i'll make a PR if it fixes the problem for everybody
+1
This solution not work for me. @mahanhaz
Did you call NotificationsIOS.consumeBackgroundQueue() ? I didn't see this instruction in docs. When I receive the notification in background, didReceiveRemoteNotification don't fire too, but the notification show in iphone
@silasmatheus if didReceiveRemoteNotification is not firing on JS, means RNNotifications module is not linked properly. i used to do it with Pod but appearantly the developer decided to remove that package from cocopod, just try to link it manually and also update your react native to the latest one. let me know if it works or not ;)
@mahanhaz: it doesn't seem to work here either, running on react-native 0.49.3 and react-native-notifications seems to be linked properly.
I put a localNotification() call on onNotificationReceivedBackground listener but I'm not receiving any call on it.
I added [RNNotificationsBridgeQueue sharedInstance].jsIsReady = YES; to my application didFinishLaunchingWithOptions until this is fixed
I'm having the same problem. Anyone figure out a good work-around?
Same problem with foreground notifications.
When app is in background state PNs are received successful. onOpened works good.
But when the app is active notificationReceivedForeground is not firing.
Changes from https://github.com/wix/react-native-notifications/issues/117#issuecomment-331699354 don't help.
Is there any update on this?
i have same issues with notificationReceivedForeground and i comment [RNNotificationsBridgeQueue sharedInstance].jsIsReady == YES as above.
The app does not display the message but has console.log ().

any one idea ????
@minhphung210 - the OS will not show a push notification in the curtain if the app is already in foreground, in this case only the listener gets fired. That is default OS behaviour.
application:didReceiveRemoteNotification:fetchCompletionHandler started firing again on foreground after setting content-available: 1 in the payload and enabling Remote notifications in Xcode -> Capabilities -> Background modes
From my experience notificationReceivedForeground will fire only after consumeBackgroundQueue() has been called.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back. Thank you for your contributions.
The issue has been closed for inactivity.
Most helpful comment
@minhphung210 - the OS will not show a push notification in the curtain if the app is already in foreground, in this case only the listener gets fired. That is default OS behaviour.