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

时间:2019-10-23 11:48:29

标签: nativescript nativescript-angular

我正在使用nativescript-angular框架开发android和iOS应用程序。我正在将nativescript-plugin-firebase插件用于fcm推送通知。在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 });
});

1 个答案:

答案 0 :(得分:0)

我现在也在为通知而苦苦挣扎,

您可以将Nativescript-Local-Notification插件与像我这样的firebase插件一起使用,您可以拥有更多自定义通知,并且可以在客户端更好地处理它们。 只需在收到Firebase回调时安排本地通知即可。

它在前台完美运行,我正在努力使其在后台运行,在后台我一直在收到Firebase通知,无法禁用它。