前台抬头通知未显示

时间:2019-07-01 22:09:43

标签: android firebase react-native

我无法使用react native在Android上显示抬头通知。我已经尝试了很多东西。这是我最终得到的代码:

const channel = new firebase.notifications.Android.Channel('test-channel', 'Test Channel', firebase.notifications.Android.Importance.Max)
                    .setDescription('My apps test channel')
                    .setLockScreenVisibility(firebase.notifications.Android.Visibility.Public)
                    .setSound('default');
    firebase.notifications().android.createChannel(channel);


    this.notificationListener = firebase.notifications().onNotification((notification) => {
        console.log("NOTIFICATION RCEIVED !!!!!!!!!!!!!!!!!!!!!!!!!");
        var notif = new firebase.notifications.Notification()
                    .setNotificationId(notification._notificationId)
                    .setTitle(notification._body)
                    .setBody(notification._body)
                    .android.setChannelId(channel._channelId)
                    .android.setSmallIcon('ic_launcher')
                    .setSound("default");

        firebase.notifications().displayNotification(notif);
    });

通知显示在设备托盘中,通知标志显示通知计数器,但没有前台通知。 我想念什么?

0 个答案:

没有答案