Firebase push notification not shows when the app at foreground in android platform

Viewed 643

I am developing both android and iOS application using the nativescript-angular framework. I am using a nativescript-plugin-firebase plugin for the fcm push notification. In the iOS platform, the notification is coming both in the foreground as well as in the background. But in android, the notification is coming only when the app is in the background.

How do we fix this issue?

My firebase initialization code:

firebase.init({
    showNotifications:true,
    showNotificationsWhenInForeground:true,

    onPushTokenReceivedCallback:(token)=>{
        console.log("onPushTokenReceivedCallback:",{token});
    },
    onMessageReceivedCallback:(message:firebase.Message)=>{

        console.log("onMessageReceivedCallback:",{message});
})
.then(()=>{
    console.log("Initialized");
})
.catch(error=>{
    console.log("Initialize",{ error });
});
1 Answers

I'm struggling with Notifications too right now,

you can use Nativescript-Local-Notification plugin alongside with firebase plugin like me, you can have much more customized notifications and can handle them much better in client-side. just schedule a local notification when you get your firebase callback.

it perfectly works in the foreground, I'm struggling to make it work in the background, in the background I just keep getting Firebase notification, can't disable it.

Related