[英]How can we use Firebase Analytics with an expo based react-native app
I am trying to add Firebase Analytics (FA) to my react-native app.我正在尝试将 Firebase Analytics (FA) 添加到我的 react-native 应用程序中。
Actually, I didn't find a problem to put Google Analytics (GA) using this library expo-analytics
.实际上,我没有发现使用这个库expo-analytics
放置谷歌分析(GA)的问题。
But apparently Firebase analytics is more powerful and it is really built for mobile apps.但显然 Firebase 分析更强大,它确实是为移动应用程序构建的。 That is why I wanted to use it in my application but the problem is that :这就是为什么我想在我的应用程序中使用它,但问题是:
I am using Expo and I cannot detach my app to add the json config files.我正在使用 Expo,我无法分离我的应用程序来添加 json 配置文件。
So my question is: is there a way to have Firebase Analytics with Expo and react-native without detach?所以我的问题是:有没有办法让 Firebase Analytics 与 Expo 和 react-native 一起使用而无需分离?
The default binding that Expo has for Firebase is based on the Firebase JavaScript SDK. Expo 对 Firebase 的默认绑定基于 Firebase JavaScript SDK。 This means that it is limited to the Firebase products that are available to web developers, which (since September 2019) includes Google Analytics for Firebase (the new name for Firebase Analytics).这意味着它仅限于可供 Web 开发人员使用的 Firebase 产品,其中(自 2019 年 9 月起)包括 Google Analytics for Firebase(Firebase Analytics 的新名称)。
Have a look at the Firebase documentation to learn how to get started with analytics on the web .查看 Firebase 文档,了解如何开始使用网络分析。
Previous, and now outdates, answer below.以前的和现在过时的,请在下面回答。 I'm leaving it here for reference for how.我把它留在这里以供参考。
The default binding that Expo has for Firebase is based on the Firebase JavaScript SDK. Expo 对 Firebase 的默认绑定基于 Firebase JavaScript SDK。 This means that it is limited to the Firebase products that are available to web developers, which unfortunately doesn't include Google Analytics for Firebase (the new name for Firebase Analytics).这意味着它仅限于可供 Web 开发人员使用的 Firebase 产品,遗憾的是不包括 Google Analytics for Firebase(Firebase Analytics 的新名称)。
This means that you'll have to rely on a third party library for binding other Firebase features into your Expo app.这意味着您将不得不依赖第三方库将其他 Firebase 功能绑定到您的 Expo 应用程序中。 And since those libraries are bridging to the native Android and iOS SDKs of Firebase, there is no way to use them without detaching/ejecting.由于这些库与 Firebase 的原生 Android 和 iOS SDK 相连,因此无法在不分离/弹出的情况下使用它们。
Also see:另见:
Check out a detailed answer of how to integrate Firebase Analytics into Expo here: https://github.com/firebase/firebase-js-sdk/issues/2244#issuecomment-558621111在此处查看有关如何将 Firebase Analytics 集成到 Expo 的详细答案: https : //github.com/firebase/firebase-js-sdk/issues/2244#issuecomment-558621111
In short:简而言之:
You can integrate Firebase Analytics into Android App using android.googleServicesFile
field.您可以使用android.googleServicesFile
字段将 Firebase Analytics 集成到 Android 应用程序中。 Works at least for SDKs 33, 34, 35.至少适用于 SDK 33、34、35。
For iOS App ios.googleServicesFile
field is missing in the Expo Docs but still can be used for Firebase Analytics.对于 iOS 应用,Expo Docs 中缺少ios.googleServicesFile
字段,但仍可用于 Firebase Analytics。 Works at least for SDK 34. Issue in Expo repo was created: https://github.com/expo/expo/issues/6379至少适用于 SDK 34。在 Expo repo 中创建了问题: https : //github.com/expo/expo/issues/6379
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.