Как отображать push-уведомления на переднем плане, даже когда приложение закрыто? - PullRequest
0 голосов
/ 17 мая 2019

Вот моя текущая реализация, она работает хорошо, когда приложение открыто, но уведомление не открывалось на переднем плане, когда приложение закрыто.

createNotificationListeners() {
    this.notificationListener = firebase.notifications().onNotification((notification) => {
        const localNotification = new firebase.notifications.Notification({
            sound: 'default',
            show_in_foreground: true,
        })
        .setNotificationId(notification.notificationId)
        .setTitle(notification.title)
        .setBody(notification.body)
        .android.setChannelId('fcm_default_channel')
        .android.setSmallIcon('@mipmap/ic_launcher')
        .android.setColor('#000000')
        .android.setPriority(firebase.notifications.Android.Priority.High);

        firebase.notifications().displayNotification(localNotification)
        .catch(err => console.error(err));
    });

    // set  channelId
    const channel = new firebase.notifications.Android.Channel(
      "fcm_default_channel",
      "Firebase Alert",
      firebase.notifications.Android.Importance.High
    );
    firebase.notifications().android.createChannel(channel);
}

У меня есть этот вопрос уже в github , но я не получил достаточно ответа

...