Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16552

react-native-firebase: onNotificationOpenedApp and getInitialNotification not working on iOS

$
0
0

I'm using Cloud Messaging from react-native-firebase 7.0.1.

I do not want to store iOS device tokens in firebase, so I'm using getAPNSToken() method and then storing it on my backend.

I'm able to send notification on a device and after pressing it, the application opens.

But when I'm trying to get message from getInitialNotification() or onNotificationOpenedApp() it always returns null/undefined.

It works every time on Android.

PushHandler.js

import React from 'react';import messaging from '@react-native-firebase/messaging';export default class PushHandler extends React.Component {  constructor(props) {    super(props);    this.messageApp = messaging();  }  componentDidMount() {    this.messageApp.onNotificationOpenedApp(remoteMessage => {      if (remoteMessage) { // <- always null on iOS        // handle notification      }    });    this.messageApp.getInitialNotification().then(initialMessage => {      if (initialMessage) { // <- always undefined on iOS        // handle notification      }    });  }  render() {    return null;  }}

Viewing all articles
Browse latest Browse all 16552

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>