我有这个问题并尝试使用我找到的所有解决方案进行修复,但仍然无效。我在 firebase cloud firestore 中的规则是:
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write : if auth != null ;
}
}
}
Run Code Online (Sandbox Code Playgroud)
而且我已经启用了匿名登录方法。
android/build.gradle:
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:4.0.1'
Run Code Online (Sandbox Code Playgroud)
android/app/build.gradle:
compile project(':react-native-firebase')
compile project(':react-native-fbsdk')
implementation project(':react-native-firebase')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-auth:16.0.4'
implementation 'com.google.firebase:firebase-firestore:17.1.0'
Run Code Online (Sandbox Code Playgroud)
Testing.js:
firebase.auth().signInAnonymously().then(()=>{
firebase.app().firestore().collection('Hello').doc('hello').set({
id:'fadsa'
}).catch((err)=>{
alert(err);
})
})
Run Code Online (Sandbox Code Playgroud)