After running expo install expo-firebase-core expo-firebase-analytics
and downloading both google-services.json
and GoogleService-Info.plist
from firebase console and placing them on the root of my project.
When i call Analytics.logEvent, expo go gives an error.
Possible Unhandled Promise Rejection (id: 0):
Error: Firebase is not configured. Ensure that you have configured 'google-services.json' correctly.
this is my TopLevelComponent.js:
import React from 'react'
import * as Analytics from 'expo-firebase-analytics';
import { createRootNavigator } from './router'
const RootNavigator = createRootNavigator()
const TopLevelComponent = props => {
const { screenProps } = props;
const { checkLogin } = screenProps;
const getActiveRouteName = navigationState => {
if (!navigationState) {
return null
}
const route = navigationState.routes[navigationState.index]
// Parse the nested navigators
if (route.routes) return getActiveRouteName(route)
return route.routeName
}
return (
<RootNavigator
onNavigationStateChange={async (prevState, currentState) => {
const currentScreen = getActiveRouteName(currentState)
const prevScreen = getActiveRouteName(prevState)
if (prevScreen !== currentScreen) {
checkLogin()
Analytics.logEvent('event')
}
}}
screenProps={props.screenProps}
/>
);
}
export default TopLevelComponent
Am i missing any other config?
Is there any other way to configure firebase-analytics besides this files?
I'm using expo-44.0.6
and expo-firebase-analytics-6.0.1
I had the same error. This is how I fixed it:
"googleServicesFile": "./GoogleService-Info.plist"
under the "iOS" section. example:
Similar for Android:
Add this for under the "web" section:
Then in the app:
const pageView = async (routeName, params) => { await Analytics.logEvent(routeName, params); };