Ahm*_*eed 5 android firebase react-native google-cloud-firestore
我正在开发一个连接到 cloud firestore 的 React Native 项目,我正在使用最新版本的 Firebase 包^7.6.1,我的应用程序面向 Android 和 iOS 我通过 iOS 测试了注册模块,并且在我测试时它可以无缝运行,没有问题它通过 Android 模拟器(谷歌像素 2)和 Android 版本 9 身份验证工作没有任何问题,但从任何集合中获取数据根本不起作用,导致以下错误:
[2019-12-31T09:25:11.274Z] @firebase/firestore:Firestore (7.6.0):无法访问 Cloud Firestore 后端。后端在 10 秒内没有响应。
我花了一天时间试图找出问题出在哪里,我发现了以下线程:https : //github.com/firebase/firebase-js-sdk/issues/283
但正如所指出的,“Android 上 xhr.send() 的原始问题已在 3 月的 React Native 版本(0.55.0)中得到解决,该问题正在跟踪此错误。” 很明显,这个问题现在已经解决了。
我也发现了这个问题:
Call to firestore collection() not working on expo
但我必须降级到旧版本的 Firebase 4.6.2,它肯定有许多已弃用的依赖项。
这是我的代码示例:
try {
const response = await firebase.auth().signInWithEmailAndPassword(email, password);
const document = await firebase.firestore().collection('users').doc(response.user.uid).get();
props.navigation.navigate('AppMain');
} catch (error) {
console.log(error);
}
Run Code Online (Sandbox Code Playgroud)
这是安全规则:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Extended the expire date
// This rule allows anyone on the internet to view, edit, and delete
// all data in your Firestore database. It is useful for getting
// started, but it is configured to expire after 30 days because it
// leaves your app open to attackers. At that time, all client
// requests to your Firestore database will be denied.
//
// Make sure to write security rules for your app before that time, or else
// your app will lose access to your Firestore database
match /{document=**} {
allow read, write: if true;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我在这里想念什么吗?如果我必须脱离 Expo 并改用 React Native Firebase 包。
| 归档时间: |
|
| 查看次数: |
1661 次 |
| 最近记录: |