-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
onNotificationOpen called when app is in foreground for iOS #987
Comments
Same issue. any fix for this? for me its triggering onnotificationOpen method twice. |
@RameshkrishnanV what I did was a hack way in my opinion, which is:
|
Thanks @DevArenaCN. Let me try! |
@RameshkrishnanV good luck. But to me I don't think that's the way onPushNotification should be called since popping up the banner doesn't necessarily meant that the notification is opened. |
yeah u r right! for me its happening only on ios. |
No I didn't. And granted I didn't test on Android because in my case the app is iOS only, so I'm not sure what the behavior is on Android. I just wanna see if this is intentional or it's a bug, to me it feels like a bug |
@DevArenaCN Thanks its working. but for onNotificationOpen triggers twice, do u have any idea? |
Hmmm I didn't see the event being triggered twice in my case, might wanna check your function for receiving the onNotificationOpen event. |
@DevArenaCN I remember need to add id for notification so ios will handle it. do u know how to add notification id to the fcm payload? please help me in this. |
apns-collapse-id? |
@DevArenaCN My solution is (line 183 of AppDelegate+FirebasePlugin.m) NSNumber *background = self.applicationInBackground;
if([background boolValue]) {
completionHandler(UNNotificationPresentationOptionAlert);
} else {
completionHandler(UNNotificationPresentationOptionNone);
} This edit prevents the need to implement extra hacks in the app. Notifications will show in background, not in foreground. |
@Farmertjes Nice. I think with these two solutions it's safe to close this issue, but I do think this should be included in the plugin. |
@DevArenaCN You can check it in meta data: |
You're right but we can use tap only if we send Notification message and not Data message. Which is problematic because it is less customizable: https://firebase.google.com/docs/cloud-messaging/concept-options |
Describe the bug
When app is running in the foreground, after receiving the notification, the onNotificationOpen function gets called immediately without the user tapping on the notification.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I would expect that this function only gets called when "opening" the notification, ie, tapping on the notification.
Plugin Version
2.0.5
Smartphone (please complete the following information):
The text was updated successfully, but these errors were encountered: