【发布时间】:2022-01-09 03:54:28
【问题描述】:
我想处理前台 Firebase 消息。 但是在 iOS 中第一次启动应用程序时,messaging().onMessage 不会触发。这在 Android 中运行良好。 确切的场景是:
- 首次启动应用程序:messaging().onMessage 未在 iOS 中触发
- 关闭并重新打开应用程序:messaging().onMessage 将触发
import { Alert } from 'react-native';
import messaging from '@react-native-firebase/messaging';
function FCMReadInForeGround() {
useEffect(() => {
const unsubscribe = messaging().onMessage(async remoteMessage => {
Alert.alert('A new FCM message arrived!', JSON.stringify(remoteMessage));
});
return unsubscribe;
}, []);
}
export default FCMReadInForeGround;```
【问题讨论】:
标签: ios firebase react-native firebase-cloud-messaging