Push-уведомление с firebase на реагировать нативное приложение - PullRequest
0 голосов
/ 17 декабря 2018

В настоящее время я пытаюсь добиться push-уведомления в моем приложении, построенном на реагировать нативно.Я могу получать уведомления, отправленные с помощью функции облачных сообщений консоли firebase, но у меня есть две проблемы

  1. Когда мое приложение работает в фоновом режиме, я могу получать только уведомления,Затем, когда он находится на переднем плане, я не могу получать уведомления в своем ящике уведомлений.

  2. Когда я нажимаю на свое уведомление, оно не содержит ничего в поле уведомления, ни текста, ни заголовка, ни чего-либо

     async componentDidMount() {
        await request_runtime_permission()
        await this.checkPermission();
        await this.createNotificationListeners();
      }
     async createNotificationListeners() {
        this.notificationListener = await firebase.notifications().onNotification((notification) => {
            console.log(notification);
            const { title, body } = notification;
            console.log(notificationOpen.notification)
            this.showAlert(title, body);
        });
       this.notificationOpenedListener = firebase.notifications().onNotificationOpened((notificationOpen) => {
            alert('onNotificationOpened')
            console.log(notificationOpen)
            const title = notificationOpen.title
            const body = notificationOpen.body
        });
      this.notificationOpenedListener = firebase.notifications().onNotificationOpened((notificationOpen) => {
            alert('onNotificationOpened')
            console.log(notificationOpen)
            const title = notificationOpen.title
            const body = notificationOpen.body
            console.log('title->', title, 'body->', body)
            this.showAlert(title, body);
        });
      const notificationOpen = await firebase.notifications().getInitialNotification();
        if (notificationOpen) {
            // alert('getInitialNotification')
            const { title, body } = notificationOpen.notification;
            console.log('title->', title, 'body->', body)
            this.showAlert(title, body);
        }}
    

I 'используя следующую версию

"react-native-firebase": "^5.1.1",
"react-native": "^0.55.4",

и следующие зависимости

 'com.google.firebase:firebase-core:16.0.4'
 "com.google.firebase:firebase-messaging:17.3.4"
 "com.google.android.gms:play-services-auth:16.0.1"
 "com.google.android.gms:play-services-base:16.0.1"
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...