我不知道如何从 firebase fcm 的推送通知中导航。我遇到了导航未定义的问题,所以我按照本指南进行操作,但它仍然没有改变屏幕。我是否缺少一些基本步骤。我试图导航到其他几个没有参数且没有导航的屏幕,但我没有收到任何错误:
https://reactnavigation.org/docs/en/navigating-without-navigation-prop.html
这是我的导航服务:
this.notificationOpenedListener = firebase.notifications().onNotificationOpened((notificationOpen) => {
const { data } = notificationOpen.notification;
NavigationService.navigate("Chat", {
chatName: `${data.channelName}`,
chatId: `${data.channelId}`
});
});
这是我的主要应用程序文件:
import SplashScreen from 'react-native-splash-screen';
const TopLevelNavigator = createStackNavigator({
ChatApp
},
{
headerMode: 'none',
navigationOptions: {
headerVisible: false,
}
});
const AppContainer = createAppContainer(TopLevelNavigator);
class App extends Component {
async componentDidMount() {
SplashScreen.hide();
}
render() {
return (
<Provider store={store}>
<AppContainer ref={navigatorRef => {
NavigationService.setTopLevelNavigator(navigatorRef);
}} />
</Provider>)
}
}
export default App;