Push-уведомление FCM не появляется, когда приложение находится на переднем плане - реагирует на нативный - PullRequest
0 голосов
/ 22 октября 2018

В приложении native native на Android все работает отлично, когда я запускаю свое приложение в режиме отладки, на переднем и заднем плане оба push-уведомления принимаются без ошибок.Но когда я генерирую подписанный APK-файл, получаются только фоновые толчки и передние толчки не принимаются.

Я проверил отладку Android (Logcat), и я вижу, что уведомления получают нормально от Firebase и не отображаются на переднем плане.

Вот мой код app.js и этот код работает.

// Firebase Cloud Messages Start
async componentDidMount() {
const notificationOpen: NotificationOpen = await firebase
    .notifications()
    .getInitialNotification();
if (notificationOpen) {
    const action = notificationOpen.action;
    const notification: Notification = notificationOpen.notification;
    var seen = [];
    alert(
        JSON.stringify(notification.data, function(key, val) {
            if (val != null && typeof val == "object") {
                if (seen.indexOf(val) >= 0) {
                    return;
                }
                seen.push(val);
            }
            return val;
        })
    );
}
const channel = new firebase.notifications.Android.Channel(
    "test-channel",
    "Test Channel",
    firebase.notifications.Android.Importance.Max
).setDescription("My apps test channel");
// Create the channel
firebase.notifications().android.createChannel(channel);
this.notificationDisplayedListener = firebase
    .notifications()
    .onNotificationDisplayed((notification: Notification) => {
        // Process your notification as required
        // ANDROID: Remote notifications do not contain the channel ID. You will have to specify this manually if you'd like to re-display the notification.
    });    this.notificationListener = firebase
    .notifications()
    .onNotification((notification: Notification) => {
        // Process your notification as required
        notification.android
            .setChannelId("test-channel")
            .android.setSmallIcon("ic_launcher");
        firebase.notifications().displayNotification(notification);
    });
this.notificationOpenedListener = firebase
    .notifications()
    .onNotificationOpened((notificationOpen: NotificationOpen) => {
        // Get the action triggered by the notification being opened
        const action = notificationOpen.action;
        // Get information about the notification that was opened
        const notification: Notification = notificationOpen.notification;
        var seen = [];
        alert(
            JSON.stringify(notification.data, function(key, val) {
                if (val != null && typeof val == "object") {
                    if (seen.indexOf(val) >= 0) {
                        return;
                    }
                    seen.push(val);
                }
                return val;
            })
        );
        firebase
            .notifications()
            .removeDeliveredNotification(notification.notificationId);
    });}
    componentWillUnmount() {
        this.notificationDisplayedListener();
        this.notificationListener();
        this.notificationOpenedListener();
    }
    // END

Также я получаю эти две ошибки:

Could not find class ‘android.app.NotificationChannelGroup’, referenced from method io.invertase.firebase.notifications.RNFirebaseNotificationManager.parseChannelGroupMap
Could not find class ‘android.app.NotificationChannel’, referenced from method io.invertase.firebase.notifications.RNFirebaseNotificationManager.parseChannelMap
...