简体   繁体   English

我们如何将 Firebase Analytics 与基于 expo 的 react-native 应用程序结合使用

[英]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.

相关问题 有什么方法可以将Firebase分析集成到expo react-native应用程序中而无需分离? - Is there any way to integrate firebase analytics into an expo react-native app without detaching? Firebase 分析仅适用于 Android(React Native Expo 应用) - Firebase analytics working only for Android (React Native Expo App) 如何在我的 react-native 应用程序中使用 firebase 模拟器? - How can I use firebase emulators with my react-native app? 如何在 React-Native 项目中实施和测试 Firebase Analytics? - How to implement and test Firebase Analytics in a React-Native project? 我应该如何将 firestore object 转换成我可以在 expo/react-native 中使用的东西? - How should I convert a firestore object into something I can use in expo/react-native? Firebase 电子商务分析 react-native - Firebase eCommerce analytics for react-native Expo react-native app with firebase phone authentication works on web, error on ios simulator and crashes with no warning on Android - Expo react-native app with firebase phone authentication works on web, error on ios simulator and crashes with no warning on Android 无法使用 Firebase 在 Android 上运行 React-Native 应用程序 - Can not run React-Native app on Android with Firebase 我可以使用 React-native、firebase 和节点 js 创建应用程序吗? - Can i create an app with React-native, firebase, and node js? 如何使用EXPO React Native应用程序从Firebase获取数据 - how to fetch data from firebase using expo react native app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM