You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can't login to the app, because I'm getting this issue Failed to get document because the client is offline.
RegisterView doesn't work too, because the button doesn't do anything.
There is problem with login, but password reseting works fine.
App is coded in SwiftUI.
Reproducing the issue
Try to login to the app with email and password, which is in the database.
Firebase SDK Version
10.29
Xcode Version
16.1
Installation Method
Swift Package Manager
Firebase Product(s)
Authentication, Firestore, Storage
Targeted Platforms
iOS
Relevant Log Output
// LoginView.swift
// opensocial
//
// Created by Filip Bukovina on 21.06.2024.
//
import SwiftUI
import Firebase
import FirebaseFirestore
import FirebaseStorage
import FirebaseCore
import FirebaseAuth
struct LoginView: View {
// MARK: User Details
@State var emailID: String = ""
@State var password: String = ""
// MARK: View Properties
@State var createAccount: Bool = false
@State var showError: Bool = false
@State var errorMessage: String = ""
@State var isLoading: Bool = false
// MARK: User Defaults
@AppStorage("user_profile_url") var profileURL: URL?
@AppStorage("user_name") var userNameStored: String = ""
@AppStorage("user_UID") var userUID: String = ""
@AppStorage("log_status") var logStatus: Bool = false
var body: some View {
VStack(spacing: 10){
Text("Hello again!")
.font(.largeTitle.bold())
.hAlign(.leading)
Text("Welcome Back,\nWe're happy, that you are back.")
.font(.title3)
.hAlign(.leading)
Text("Version 0.1(9)")
.font(.caption)
.hAlign(.leading)
VStack(spacing: 12){
TextField("Email", text: $emailID)
.textContentType(.emailAddress)
.border(1, .gray.opacity(0.5))
.padding(.top,25)
SecureField("Password", text: $password)
.textContentType(.emailAddress)
.border(1, .gray.opacity(0.5))
Button("Reset password?", action: resetPassword)
.font(.callout)
.fontWeight(.medium)
.tint(.black)
.hAlign(.trailing)
Button(action: loginUser){
// MARK: Login Button
Text("Sign in")
.foregroundColor(.white)
.hAlign(.center)
.fillView(.black)
}
.padding(.top,10)
}
// MARK: Register Button
HStack{
Text("Ready to use secure social?")
.foregroundColor(.gray)
Button("Register Now"){
createAccount.toggle()
}
.fontWeight(.bold)
.foregroundColor(.black)
}
.font(.callout)
.vAlign(.bottom)
}
.vAlign(.top)
.padding(15)
.overlay(content: {
LoadingView(show: $isLoading)
})
// MARK: Register View VIA Sheets
.fullScreenCover(isPresented: $createAccount) {
RegisterView()
}
// MARK: Displaying Alert
.alert(errorMessage, isPresented: $showError, actions: {})
}
func loginUser(){
isLoading = truecloseKeyboard()
Task{
do{
// With the help of Swift Concurrency Auth can be done with Single Line
try await Auth.auth().signIn(withEmail: emailID, password: password)
print("User Found")
}catch{
await setError(error)
}
}
}
// MARK: If User if Found then Fetching User Data From Firestore
func fetchUser()async throws{
guard let userID = Auth.auth().currentUser?.uid else{return}
let user = try await Firestore.firestore().collection("Users").document(userID).getDocument(as: User.self)
// MARK: UI Updating Must be Run On Main Thread
await MainActor.run(body: {
// Setting UserDefaults data and Changing App's Auth Status userUID = userID userNameStored = user.username profileURL = user.userProfileURL logStatus = true }) } func resetPassword(){ Task{ do{ // With the help of Swift Concurrency Auth can be done with Single Line try await Auth.auth().sendPasswordReset(withEmail: emailID) print("Link Sent") }catch{ await setError(error) } } } // MARK: Displaying Errors VIA Alert func setError(_ error: Error)async{ // MARK: UI Must be Updated on Main Thread await MainActor.run(body: { errorMessage = error.localizedDescription showError.toggle() isLoading = false }) } } struct LoginView_Previews: PreviewProvider { static var previews: some View { LoginView() } }
If using Swift Package Manager, the project's Package.resolved
Expand Package.resolved snippet
Replace this line with the contents of your Package.resolved.
If using CocoaPods, the project's Podfile.lock
Expand Podfile.lock snippet
Replace this line with the contents of your Podfile.lock!
The text was updated successfully, but these errors were encountered:
No, I was just highlighting the fact that the error you're seeing is a result of getting an "unavailable" error code.
Are you able to perform any Firestore operation?
Can your device reach the network?
Are you targeting the Firestore backend or emulator?
Do your security rules allow access to the document you are trying to access?
Description
Can't login to the app, because I'm getting this issue Failed to get document because the client is offline.
RegisterView doesn't work too, because the button doesn't do anything.
There is problem with login, but password reseting works fine.
App is coded in SwiftUI.
Reproducing the issue
Try to login to the app with email and password, which is in the database.
Firebase SDK Version
10.29
Xcode Version
16.1
Installation Method
Swift Package Manager
Firebase Product(s)
Authentication, Firestore, Storage
Targeted Platforms
iOS
Relevant Log Output
If using Swift Package Manager, the project's Package.resolved
Expand
Package.resolved
snippetReplace this line with the contents of your Package.resolved.
If using CocoaPods, the project's Podfile.lock
Expand
Podfile.lock
snippetReplace this line with the contents of your Podfile.lock!
The text was updated successfully, but these errors were encountered: