React Navigation从Firebase推送通知导航

问题描述 投票:0回答:1

我不知道如何从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}`
      });

});

这是我的主要App文件:

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;
react-native push-notification react-navigation react-native-push-notification
1个回答
0
投票
const TopLevelNavigator = createStackNavigator({ ChatApp: { screen: ChatApp, }, Chat: { screen: ChatScreen, } });
© www.soinside.com 2019 - 2024. All rights reserved.