firebasereact-nativeexpofirebase-analytics

How to properly initialize Firebase Analytics in a React Native Expo app using @firebase?


I'm trying to integrate Firebase Analytics into my React Native Expo app using the official @firebase library (I already use other services successfully). However, I'm encountering the following warning:

@firebase/analytics: Analytics: Firebase Analytics is not supported in this environment. 
Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. 
Details: (1) Cookies are not available. (analytics/invalid-analytics-context).

I understand that this is due to the absence of cookies in the React Native environment. How can I go around this the same way the unofficial rnfirebase library (which I don't want to use) has done it?


Solution

  • I ended up using a combination of @firebase and rnfirebase in my project, where the latest is used to implement Firebase Analytics.

    The other solution I found was to write native code and use the native sdks for iOS and Android from Firebase to implement Analytics in my project, but this would have required a lot of work which I wanted to avoid.