如何在React-Native项目中实施和测试Firebase Analytics? [英] How to implement and test Firebase Analytics in a React-Native project?
问题描述
从阅读中我了解到,Firebase正式支持react-native.
I have learned from reading that Firebase officially supports react-native.
https://firebase .googleblog.com/2016/01/the-beginners-guide-to-react-native-and_84.html
我已遵循上面的链接并执行了以下步骤:
I have followed the above link and performed these steps:
-
npm install firebase --save
- 打开
index.ios.js
并导入Firebase
npm install firebase --save
- Opened
index.ios.js
and imported firebase
从"firebase"中导入*作为firebase;
import * as firebase from 'firebase';
- 初始化Firebase
const firebaseConfig = {
apiKey: "<your-api-key>",
authDomain: "<your-auth-domain>",
databaseURL: "<your-database-url>",
storageBucket: "<your-storage-bucket>",
,
};
const firebaseApp = firebase.initializeApp(firebaseConfig);
我在上述字段中输入了所有正确的值.据我了解,这应该在我的项目中启用Firebase分析,并且应该在Firebase控制台中看到会话报告.但是我什么也看不到.
I have put all the right values in the above fields. From my understanding, this should enable Firebase analytics in my project and I should see session reporting in Firebase console. But I can't see anything.
我在这里错过了什么吗?还可以通过任何方法使Firebase登录本机以使我知道发生了什么事吗?
Am I missing anything here? Also is there any way to get Firebase logs in react native so that I can know what's happening?
推荐答案
Firebase Web SDK(包括实时数据库)可与React Native一起使用.但是,Firebase当前不提供分析作为Web SDK的一部分.要启用分析,您需要围绕本机SDK实施包装程序,或使用诸如 https之类的库://github.com/fullstackreact/react-native-firestack .
The Firebase web SDK (including real-time database) works with React Native. However, Firebase does not currently offer analytics as part of the Web SDK. To enable analytics, you would need to implement a wrapper around the native SDKs or use a library such as https://github.com/fullstackreact/react-native-firestack.
这篇关于如何在React-Native项目中实施和测试Firebase Analytics?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!