小编mys*_*elf的帖子

我的屏幕名称未出现在Firebase Analytics仪表板中

我正在尝试与react-navigation一起跟踪react-native-firebase上的屏幕名称。

这是我的代码。

const tracker = firebase.analytics()

function getCurrentRouteName(navigationState) {
  if (!navigationState) {
    return null;
  }
  const route = navigationState.routes[navigationState.index];
	// dive into nested navigators
  if (route.routes) {
    return getCurrentRouteName(route);
  }
  return route.routeName;
}

export default class AppNavigation extends Component {

	render() {
		StatusBar.setBarStyle('light-content');

		return (
			<MainScreenNavigator 
				onNavigationStateChange={(prevState, currentState) => {
					const currentScreen = getCurrentRouteName(currentState);
					const prevScreen = getCurrentRouteName(prevState);
		
					if (prevScreen !== currentScreen) {
						// the line below uses the Google Analytics tracker
						// change the tracker here to use other …
Run Code Online (Sandbox Code Playgroud)

react-native firebase-analytics react-native-navigation react-native-firebase

5
推荐指数
1
解决办法
1458
查看次数