-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Not receiving notifications when app is closed IOS #306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@darkcoderrises Are you seeing the notification popup in the OS whilst the app is closed / in the background? Or are you not receiving this either? |
@chrisbianca No I am not receiving. |
Have you called |
Yeah I call request permission at the start of the app. I receive notifications when app is open, but not when the app is closed. |
Have you enabled:
If you're not receiving the notifications when in the background, this is a setup issue with FCM, not with react-native-firebase |
Yeah, I have enabled them both. Is there anything else that is required for me to configure for background notifications? |
Yes,
|
I am getting the local notification and I have followed the procedure as in the link provided. But I still can't receive notification when it is closed. |
maybe there is a problem with this:
Sending a message from your api should look like this: firebase.messaging().sendToDevice(notificationId, {notification: {title: 'hey', body: 'test',},}, {priority: 'high',}) |
@chrisbianca @Jobeso I receive the notification in the objective-c code (AppDelegate.m). `
from where it is supposed to be passed to rn firebase messaging. I think that is the point when it should create a notification. |
Any luck solving this? i'm having the same issue |
I have the same issue with this and what i did to solve is put this code request for permission after if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_7_1) {
// iOS 7.1 or earlier. Disable the deprecation warnings.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
UIRemoteNotificationType allNotificationTypes =
(UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeBadge);
[application registerForRemoteNotificationTypes:allNotificationTypes];
#pragma clang diagnostic pop
} else {
// iOS 8 or later
// [START register_for_notifications]
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) {
UIUserNotificationType allNotificationTypes =
(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
UIUserNotificationSettings *settings =
[UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
} else {
// iOS 10 or later
#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
// For iOS 10 display notification (sent via APNS)
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
UNAuthorizationOptions authOptions =
UNAuthorizationOptionAlert
| UNAuthorizationOptionSound
| UNAuthorizationOptionBadge;
[[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:authOptions completionHandler:^(BOOL granted, NSError * _Nullable error) {
}];
#endif
}
[[UIApplication sharedApplication] registerForRemoteNotifications];
// [END register_for_notifications]
} This comes from firebase quickstart iOS and same with requestPermission. Notice both are successful asking permission. But requestPermission cannot receive notification when app close. Not sure why. Can anyone look into this? |
For me I fixed this by adding my cert to the firebase web console. But I am wondering where is all the documentation for this? Is this everything??? |
Thanks for reporting. We're aware of lots of issues with notifications and will be addressing them all as part of the v3.2.0 release stream. Please see #595 for updates. |
QuestionShould a closed app be capable of displaying a notification sent Monday, when the user launches the app Friday, for example? Currently I can:
I am not clear if I should be able to display notifications when app is opened, if user ignored or did not see the the initial home screen notification. Badges I do not understand at all. I was hoping a badge would display if user did not see a notification sent when app was closed. Tips and suggestions much appreciated. |
im not able to get foreground notification ...background notification works constructor(props) { Android it works for both cases but in ios foreground notification isnt working any help? |
Good news, the long awaited alpha of our messaging and notifications overhaul is now available!! Check out the release notes here: https://github.com/invertase/react-native-firebase/releases/tag/v4.0.0-alpha.1 If you have any comments and suggestions or want to report an issue, come find us on Discord |
How to receive data-only push from FCM on IOS when the app is closed? There is no info regarding the data-only message handler in IOS when the app is closed. Please advice something |
I'm having the same problem. data-only messages do not arrive when my app is closed. |
Same here for IOS App foreground : Notification received There is a workaround to make it works ? Because we need to use local notifications to display data, we cannot use remote notification. |
@chrisbianca There is a solution to handle data-only message when app is closed on IOS ? |
Hi, we have the same issue, however we noted that in the first install of the app, the notifications on iOS work for background. Unfortunately, after the app is closed, not just the notifications didn't come when it's closed, also when you open the app again nothing happens which any kind of notifications. What could be wrong? or what should I'm missing on it? Thanks. |
Hey any update guys I'm not getting any console log when app is closed in background notification listener though notification appears |
@atultiwaree when discussing firebase messaging, always include the JSON you were sending to the FCM REST API to trigger the behavior My guess is you using a notification block - the underlying firebase-ios-sdk posts a visible local notification in this case but does not wake up your app, no handlers are called unless / until the user interacts with the notification (then. you should be able to use react-native's notification opened app handler, and perhaps the onMessage handler)) |
@mikehardy thanks for replay you're right when I sent payload with notifications key it didn't triggered "onBackground event" instead when I sent only data it triggered, actually in Android I was able to see when background notification came and waked my app in background but in iOS I was not able after killing app I was not getting any log in xcode I'll be more than happy if you please suggest me some debugger and debugging tips for iOS because terminal works well in Android but not in iOS and flipper is also their for Android but not able to use in iOS because of firebase I confirmed weather background event fired in iOS or not using AsyncStorage 😄 |
So with iOS data only is not reliable. You ha e to use a notification block. With a notification block your app doesn't get control and the notification is plain. Only way we know around this is notifee.app to do an extension thing that allows skinning the notification at least |
@mikehardy correct with notification payload it shows UI Alert without this it does not show, but using notifee + notification data payload it works just fine, mine problem is I'm not able to get logs when my ios app closed in actual device and for single change I've to re run the app but in android everything just works fine even flipper in iOS I can't even use flipper, please suggest me some solution debugging setup ? so that I can handle background process of app like mutating storage etc. |
Console.app with device plugged in or xsimctl can view device logs. Use console.log in your app with strings that are easy to filter on. Flipper is going away in react-native anyway based on upstream discussion. Not having it is not a big deal. |
@mikehardy Thank-You for your help, you're right instead of flipper I've found reactotron for debugging it worked just fine though JS Logs are still logging in flipper, |
Uh oh!
There was an error while loading. Please reload this page.
I have an app which uses react-native-firebase. I followed the initialisation steps provided for installing the app and for cloud messaging. Now when I use firebase console to send notification to a single user (haven't tried sending to a bunch, but I guess result would be the same), I receive the notification if the app is open, otherwise not. I read somewhere that when app is closed, one doesn't receive notification in the code, rather user see's a notification in notification bar and when clicked on, it invokes getInitialNotification().
Podfile:
Notification Listener component
Notification I am sending:
{
"registration_ids" : [""],
"notification": {
"title" : "Hi",
"body" : "Heyy"
},
"priority": "high"
}
The text was updated successfully, but these errors were encountered: