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;
}
}
