Я быстро разрабатываю приложение и использую Firestore для хранения своих данных. Это первый раз, когда я использую Firebase.
Вчера я подключил firebase
и firestore
к своему проекту, и все работало нормально. Сегодня внезапно я получил ошибку, что не удалось подключиться к бэкэнду Firestore.
2020-04-03 13: 37: 25.851931 + 0200 Bouwresten [14277: 2448929] 6.21.0 - [Firebase / Firestore] [I-FST000001] Не удалось связаться с бэкэндом Cloud Firestore. Соединение не удалось 1 раз. Самая последняя ошибка: сетевое подключение изменено. Обычно это указывает на то, что в данный момент ваше устройство не имеет исправного соединения Inte rnet. Клиент будет работать в автономном режиме до тех пор, пока не сможет успешно подключиться к бэкэнду.
Теперь я точно знаю, что у моего компьютера хорошее соединение, и я использую симулятор XCode для проверки приложение. Кто-нибудь знает, в чем может быть проблема?
Это мой appdelegate.swift
//
// AppDelegate.swift
// Bouwresten
//
// Created by Brecht Verhelst on 25/03/2020.
// Copyright © 2020 Brecht Verhelst. All rights reserved.
//
import UIKit
import Firebase
import FirebaseFirestore
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FirebaseApp.configure()
return true
}
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
}
Это класс, в котором я использую Firestore для получения данных, он называется dbhelper
//
// DBHelper.swift
// Bouwresten
//
// Created by Brecht Verhelst on 02/04/2020.
// Copyright © 2020 Brecht Verhelst. All rights reserved.
//
import Foundation
import Firebase
import FirebaseFirestore
class DBHelper
{
var Users = [User]()
var Products = [Product]()
init() {
getUsers()
}
func getUsers() {
Firestore.firestore().collection("Gebruikers").getDocuments() { (querySnapshot, err) in
if let err = err {
print("Error getting documents: \(err)")
} else {
for document in querySnapshot!.documents {
let user:User = User(Voornaam: document.get("Naam") as! String, Familienaam: document.get("Familienaam") as! String, Email: document.get("Email") as! String, Wachtwoord: document.get("Wachtwoord") as! String,
Stad: document.get("Stad") as! String, Postcode: document.get("Postcode") as! String, Straat: document.get("Straat") as! String, Nummer: document.get("Nummer") as! String, Added_on: document.get("Added_on") as! String)
self.Users.append(user)
print(self.Users.count)
}
}
}
}
func getProducts() {
Firestore.firestore().collection("Producten").getDocuments() { (querySnapshot, err) in
if let err = err {
print("Error getting documents: \(err)")
} else {
for document in querySnapshot!.documents {
let product:Product = Product(Titel: document.get("Titel") as! String, Beschrijving: document.get("Beschrijving") as! String, Prijs: document.get("Prijs") as! Double, Gereserveerd: document.get("Gereserveerd") as! Bool, Added_on: document.get("Added_on") as! String, Gebruiker_id: document.get("gebruiker_ID") as! String)
self.Products.append(product)
}
}
}
print(self.Products.count)
}
}
Надеюсь, кто-нибудь может мне помочь с этой проблемой.