【发布时间】:2021-08-23 08:38:24
【问题描述】:
我以前使用过 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 应用程序中运行,但现在不再可用。
【问题讨论】:
标签: javascript android firebase react-native react-native-android