I have implemented Firebase Auth (sign in with Apple) and Firebase firestore in an app live on the App Store. I implemented a listener for authentication state in the scene delegate from the firebase documentation. https://firebase.google.com/docs/auth/ios/start
It checks if the user is logged in or not. The code aims to present a login view controller if there is no user registered or the main view controller if the user already created an account & hasn't logout at the start up.
However, I had feedback from users that after sign out & login, the app keep crashing both in live or in testFlight, I don't have anything reported in Crashlytics or App Store Connect. I am looking for help from people that encountered the same problems.
var handle: AuthStateDidChangeListenerHandle?
handle = Auth.auth().addStateDidChangeListener { (auth, user) in
if((user) != nil){
let home = TabBar()
home.selectedIndex = 1
self.window?.rootViewController = home
} else if((user) == nil) {
print("Not Logged in")
let signup = SignUpVC()
self.window?.rootViewController = signup
}
}