This is how to solve the issue on the messaging module example.
import { getMessaging, requestPermission, setBackgroundMessageHandler, onMessage, getToken, onNotificationOpenedApp, getInitialNotification, subscribeToTopic, hasPermission } from '@react-native-firebase/messaging';
messaging()
calls and use imported methods directly. All of them (except getMessaging
) require first additional argument: messaging instance.Old code:
messaging().getInitialNotification().then(message => this.catchMessage(message));
var token = await messaging().getToken();
New code:
const messagingInstance = getMessaging();
getInitialNotification(messagingInstance).then(message => this.catchMessage(message));
var token = await getToken(messagingInstance);
Big example code is given here: https://github.com/invertase/react-native-firebase/issues/8282#issuecomment-2760400136