Setup with Firebase (Android) and APNs (iOS):
1import messaging from "@react-native-firebase/messaging";23async function requestPermission() {4 const auth = await messaging().requestPermission();5 if (auth) {6 const token = await messaging().getToken();7 // Send token to server8 }9}1011messaging().onMessage(async (remoteMessage) => {12 // Foreground notification13 showLocalNotification(remoteMessage);14});1516messaging().onNotificationOpenedApp((remoteMessage) => {17 // Background tap18 navigateToScreen(remoteMessage.data);19});
Best practices: