-
Notifications
You must be signed in to change notification settings - Fork 439
[ios][messaging] onMessaggeReceived callback not triggered when showNotificationsWhenInForeground is true #1371
Comments
I think this is related to this code: nativescript-plugin-firebase/src/messaging/messaging.ios.ts Lines 536 to 548 in e2da843
I think this is a wrong logic as there can be cases (like in my app right now) where you need to also process the callback AND show a notification when app is foreground. Considering under android the callback is always called. @EddyVerbruggen can we at least have a config option that allows processing the callback in this case? |
…otificationsWhenInForeground is true #1371
I guess that makes sense, and you can always still use the nativescript-plugin-firebase/src/messaging/messaging.ios.ts Lines 532 to 547 in 56ceba2
|
@EddyVerbruggen ups this fix has broken my app logic But for now, I can't figure out how to detect such behavior. Is it possible to distinguish these two situations with current implementation? |
@ycherniavskyi did you came up with a solution for this? I am experiencing the same issue in my app. |
@ditoglez yes I came up, but with the really dirty solution, so don't tell anyone who shown it to you 🤣: onMessageReceivedCallback: (message: firebase.Message) => {
// ...
if (message.foreground) {
if (isIOS) { // HACK: to skip processing the notification which received in foreground check stack trace
// (this processing appear after resolving the issue https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues/1371),
// the notification will remain in notification center because of `showNotificationsWhenInForeground` flag
// and will be processed on click on it
const stack = new Error().stack;
if (stack.includes("userNotificationCenterWillPresentNotificationWithCompletionHandler")) {
console.log("onMessageReceivedCallback skipped")
return;
}
}
// ...
}
// ...
processPushMessageHelper(message);
} |
…otificationsWhenInForeground is true #1371
I've now (v 10.1.0) added the |
@EddyVerbruggen thank you for the added flag, I replaced my hack with it and everything works as expected! |
On iOS if I set
showNotificationsWhenInForeground
totrue
theonMessagReceivedCallback
is not triggered when my app is in the foreground. Is it supposed to work like this? Can we make it so that the callback is also trigerred?The text was updated successfully, but these errors were encountered: