NativeScript / firebase

Modular Firebase 🔥 implementation for NativeScript. Supports both iOS & Android platforms for all Firebase services.
https://docs.nativescript.org/plugins/firebase-core.html
Apache License 2.0
56 stars 49 forks source link

showNotificationsWhenInForeground not working on android #20

Closed eikaramba closed 2 years ago

eikaramba commented 2 years ago

even when i set the boolean to true it does not show the notification when the app is in foreground. i can see that the variable is not used at all in the android source code. is that right? https://github.com/NativeScript/firebase/blob/af2b24ccc6f07727c09f1723537f32e0fb0066f4/packages/firebase-messaging/index.android.ts

eikaramba commented 2 years ago

mhm okay it seems in the original firebase plugin this wasn't working for android as well ;) https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues/1136

but i guess it could work. i mean i see the push output in the console, so theoretically the plugin could show a local notification. maybe out of scope however here, not sure.

eikaramba commented 2 years ago

using https://github.com/NativeScript/plugins/tree/main/packages/local-notifications now:

if(isAndroid && message.foreground){
    LocalNotifications.schedule([{
        title: message.title,
        body: message.body,
        icon: 'res://notification_icon',
        silhouetteIcon: 'res://notification_icon',
        thumbnail: false,
        forceShowWhenInForeground:  true
    }]);
}