0

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

1 回答 1

0

问题是我需要在同一个导航器中放置另一个堆栈。一旦我添加它开始工作

const TopLevelNavigator = createStackNavigator({
  ChatApp: {
    screen: ChatApp,
  },
  Chat: {
    screen: ChatScreen,
  }
});
于 2019-12-22T03:00:05.950 回答