Javascript react本机firebase fcm setBackgroundMessageHandler不工作
我正在创建一个函数,用于在FCM的setBackgroundMessageHandler事件中通过异步存储存储数据 我正在使用@react native firebase/消息传递。 SetBackgroundMessageHandler不工作 我在上阅读了教程,并从firebase网站发送了它 除了当前的setBackgroundMessageHandler函数外,其他一切都正常工作 我已经找了很长时间了,但是我找不到答案 我用一个真正的设备测试了它。 推送消息正常显示,但不会发生setBackgroundMessageHandler事件 package.jsonJavascript react本机firebase fcm setBackgroundMessageHandler不工作,javascript,firebase-cloud-messaging,react-native-firebase,Javascript,Firebase Cloud Messaging,React Native Firebase,我正在创建一个函数,用于在FCM的setBackgroundMessageHandler事件中通过异步存储存储数据 我正在使用@react native firebase/消息传递。 SetBackgroundMessageHandler不工作 我在上阅读了教程,并从firebase网站发送了它 除了当前的setBackgroundMessageHandler函数外,其他一切都正常工作 我已经找了很长时间了,但是我找不到答案 我用一个真正的设备测试了它。 推送消息正常显示,但不会发生setBac
"@react-native-firebase/app": "^11.2.0",
"@react-native-firebase/messaging": "^11.2.0",
"@react-native-firebase/ml": "^11.2.0",
index.js
import React from 'reactn';
import messaging from '@react-native-firebase/messaging';
import {AppRegistry} from 'react-native';
import App from './App';
messaging().setBackgroundMessageHandler(async remoteMessage => {
// ...is not working
console.log('Message handled in the background!', remoteMessage);
});
function HeadlessCheck({isHeadless}) {
if (isHeadless) {
return null;
}
return <App />;
}
AppRegistry.registerComponent('AppName', () => HeadlessCheck);
React.useEffect(() => {
var _resultList = resultList;
const unsubscribe = messaging().onMessage(async remoteMessage => {
//...is working
}
messaging().onNotificationOpenedApp(remoteMessage => {
//...is working
});
// Check whether an initial notification is available
messaging()
.getInitialNotification()
.then(remoteMessage => {
if (remoteMessage) {
//...is working
}
});
}, []);