[英]How to connect Firebase emulator in Swift by using typescript?
我正在開發 Swift 應用程序連接 Typescript 中的 Firebase 模擬器。
import SwiftUI
import Firebase
import FirebaseAuth
import FirebaseStorage
import FirebaseFirestore
import FirebaseFirestoreSwift
import FirebaseFunctions
import FirebaseFunctionsSwift
@main
struct HelloApp: App {
init(){
FirebaseApp.configure()
//Auth
Auth.auth().useEmulator(withHost:"localhost", port:9099)
//Storage
Storage.storage().useEmulator(withHost:"localhost", port:9199)
//Firestore
let settings = Firestore.firestore().settings
settings.host = "localhost:8080"
settings.isPersistenceEnabled = false
settings.isSSLEnabled = false
Firestore.firestore().settings = settings
//Cloud Function
Functions.functions().useEmulator(withHost: "http://localhost", port: 5001)
}
var body: some Scene {
WindowGroup {
MainContent()
}
}
}
我收到了這個錯誤。 [Firebase/Firestore][I-FST000001] WatchStream (14ed17248) Stream error: 'Unknown: An internal error has occurred, print and inspect the error details for more information.
和日志文件,我得到了這個錯誤expected an unsecured JWT, the emulator does not validate JWTs and IS NOT SECURE
。
我應該如何解決這些問題。 請教我這些。 謝謝你。
您可以嘗試通過在調用FirebaseApp.configure()
之后將Firestore.firestore().settings
移動到右側來嘗試更改代碼另外請確保您仍然必須將FIREBASE_AUTH_EMULATOR_HOST 環境變量設置為本地主機,因為本地主機需要獲得授權作為 Firebase 用戶使用授權。 在此處檢查類似示例
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.