![](/img/trans.png)
[英]Error: @firebase/firestore: Firestore (9.6.11): Could not reach Cloud Firestore backend
[英]@firebase/firestore: Firestore (8.6.5): Could not reach Cloud Firestore backend
我以前使用的是 expo 但我退出了我的项目,一切正常,除了我的 firebase 连接。 它说:@firebase/firestore:Firestore (8.6.5):无法访问 Cloud Firestore 后端。 后端在 10 秒内没有响应。
import firebase from 'firebase';
import '@firebase/firestore';
const firebaseApp = firebase.initializeApp({
apiKey: 'AIzaSyALTdavPNQReVJNWyc2aF8DfexzxzDoXB0',
authDomain: 'projetofinal-e1147.firebaseapp.com',
projectId: 'projetofinal-e1147',
storageBucket: 'projetofinal-e1147.appspot.com',
messagingSenderId: '546669005614',
appId: '1:546669005614:web:1b06c375565e04b4c888bf',
measurementId: 'G-KLJBEWBR3S',
});
class Fire {
constructor(callback) {
this.init(callback);
}
init(callback) {
if (!firebase.apps.length) {
firebase.initializeApp(firebaseConfig);
}
firebase.auth().onAuthStateChanged(user => {
if (user) {
callback(null, user);
} else {
firebase
.auth()
.signInAnonymously()
.catch(error => {
callback(error);
});
}
});
}
getLists(callback) {
let ref = this.ref.orderBy('color');
this.unsubscribe = ref.onSnapshot(snapshot => {
lists = [];
snapshot.forEach(doc => {
lists.push({id: doc.id, ...doc.data()});
});
callback(lists);
});
}
addList(list) {
let ref = this.ref;
ref.add(list);
}
deleteList(list) {
let ref = this.ref;
ref.doc(list.id).delete();
}
updateList(list) {
let ref = this.ref;
ref.doc(list.id).update(list);
}
get userId() {
return firebase.auth().currentUser.uid;
}
get ref() {
return firebase
.firestore()
.collection('users')
.doc(this.userId)
.collection('lists');
}
detach() {
this.unsubscribe();
}
}
export default Fire;
这是我的 Firebase 文件,它在我的 expo 应用程序中工作,但它不再是了。
添加这个:
if (!firebase.apps.length) {
firebase.initializeApp(firebaseConfig);
+ firebase.firestore().settings({ experimentalForceLongPolling: true, merge: true });
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.