firebase icon indicating copy to clipboard operation
firebase copied to clipboard

Android `showNotificationsWhenInForeground` not working

Open vallemar opened this issue 2 years ago • 4 comments

In android when i set showNotificationsWhenInForeground to true the app doesn't show the notification if it is in the foreground

firebase().messaging().showNotificationsWhenInForeground = true;

https://github.com/NativeScript/firebase/blob/main/packages/firebase-messaging/README.md#always-show-notifications-when-the-application-is-in-foreground

vallemar avatar Mar 26 '23 10:03 vallemar

I guess this issue is still not resolved, is that correct?

jskorlol avatar Jun 22 '24 06:06 jskorlol

I've been using local-notifications as a workaround for this for a while now.

SingleMalted avatar Jul 01 '24 23:07 SingleMalted

@SingleMalted So you solved it by displaying a message using local-notifications when receiving a message via messaging.onMessage in firebase?

jskorlol avatar Jul 05 '24 09:07 jskorlol

yep, basically. It checks that the app is in the foreground and is Android. If so, it schedules a local notification.

It's not ideal but it works well enough.

SingleMalted avatar Jul 16 '24 22:07 SingleMalted