当应用程序在 Android 平台中处于前台时,Firebase 推送通知不显示

Ari*_*han 5 nativescript nativescript-angular

我正在使用 nativescript-angular 框架开发 android 和 iOS 应用程序。我正在为 fcm 推送通知使用nativescript-plugin-firebase 插件。在 iOS 平台中,通知在前台和后台都出现。但是在android中,只有当应用程序在后台时才会收到通知。

我们如何解决这个问题?

我的 Firebase 初始化代码:

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 });
});
Run Code Online (Sandbox Code Playgroud)