简体   繁体   English

无法访问 Firestore 后端

[英]Could not Reach Firestore Backend

I'm creating a swift 4 ios application and would like to use Firestore to store all my data.我正在创建一个 swift 4 ios 应用程序,并想使用 Firestore 来存储我的所有数据。 I've gone through the getting started guides and watched the online tutorial, but I continue to get the error:我已经阅读了入门指南并观看了在线教程,但我仍然收到错误消息:

"4.8.1 - [Firebase/Firestore][I-FST000001] Could not reach Firestore backend." “4.8.1 - [Firebase/Firestore][I-FST000001] 无法访问 Firestore 后端。”

my cocoapods file contains:我的 cocoapods 文件包含:

pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Firestore'

In AppDelegate : I import Firebase and in didFinishLaunchingWithOptions I do FirebaseApp.configure()AppDelegate :我import Firebase并在didFinishLaunchingWithOptions执行FirebaseApp.configure()

In viewController: import Firebase (have also tried import FirebaseFirestore )在 viewController: import Firebase (也试过import FirebaseFirestore )

I define:我定义:

var docRef : DocumentReference! 

and in viewDidLoad:在 viewDidLoad 中:

docRef = Firestore.firestore().document("test/test")

docRef.getDocument { (docSnapshot, error) in
   guard let docSnapshot = docSnapshot, docSnapshot.exists else {return}
   let myData = docSnapshot.data()
   let val = myData!["name"] as? integer_t ?? 1
   print(val)
}

and I get the error我得到了错误

"4.8.1 - [Firebase/Firestore][I-FST000001] Could not reach Firestore backend." “4.8.1 - [Firebase/Firestore][I-FST000001] 无法访问 Firestore 后端。”

I have my firestore set to test mode so all reads and writes should be allowed.我将我的 firestore 设置为测试模式,因此应该允许所有读取和写入。 Anyone of ideas as to why I can't connect to the backend?关于为什么我无法连接到后端的任何想法?

In my case, I was trying to add data into " Real-Time Database " of Firebase Console and then read in my new AngularFire2 app.就我而言,我试图将数据添加到 Firebase 控制台的“ Real-Time Database ”中,然后在我的新AngularFire2应用程序中读取AngularFire2 Realized after a while that it has to be "Cloud Firestore".一段时间后意识到它必须是“Cloud Firestore”。

You first need to get reference to the collection containing that document, try:您首先需要获取对包含该文档的集合的引用,请尝试:

let docRef = db.collection("test").document("test")

docRef.getDocument { (document, error) in
    if let document = document {
        print("Document data: \(document.data())")
    } else {
        print("Document does not exist")
    }
}

当我在模拟器上“重置所有内容和设置”时,问题自行解决。

Maybe it is late but I just resolved this problem and it was hard to find the answer so I share it.也许已经晚了,但我刚刚解决了这个问题,很难找到答案,所以我分享了它。 You have to sign in first and the problem will be solved.您必须先登录,问题才会得到解决。 The code below is an example for sign in with Anonymous user.下面的代码是使用匿名用户登录的示例。 Hope it is useful for you希望对你有用

Auth.auth().signInAnonymously { (result, error) in
        print("result:\(result) " )
        print("error: \(error)")
    }

refer: https://firebase.google.com/docs/auth/ios/custom-auth参考: https : //firebase.google.com/docs/auth/ios/custom-auth

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 [Firestore] [I-FST000001]无法到达Firestore后端 - [Firestore][I-FST000001] Could not reach Firestore backend 连接到 firebase/firestore 时出错:无法到达 Cloud Firestore 后端 - Error when connecting to firebase/firestore: Could not reach Cloud Firestore backend Firestore:无法访问 Cloud Firestore 后端。 连接失败1次 - Firestore: Could not reach Cloud Firestore backend. Connection failed 1 times Swift DispatchGroup导致错误:[Firebase / Firestore] [I-FST000001]无法到达Cloud Firestore后端 - Swift DispatchGroup causes error: [Firebase/Firestore][I-FST000001] Could not reach Cloud Firestore backend 为什么NSURLConnection无法到达后端? - Why does NSURLConnection fail to reach the backend? CocoaPods 找不到 pod“cloud_firestore”的兼容版本 - CocoaPods could not find compatible versions for pod "cloud_firestore" 更新索引值时,Firestore addSnapshotListener 无法收听文档更新 - Firestore addSnapshotListener could not listen to update on document when updating the index value 从另一个先前的视图控制器获取的变量,但我无法达到该值(零错误)? - The variable taken from another previous view controller but I could not reach that value(nil error)? iOS 客户端、flask 与 node.js 与 ZBF12E1515C25AB7D8C0352F 使用哪个后端服务? - Which backend service to use for iOS client, flask vs node.js vs firebase firestore? 找不到具有指定主机名的服务器。 加载页面时出错。 条纹,firebase 后端 - A server with the specified hostname could not be found. Error loading page. Stripe, firebase backend
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM