So I saw this from another post. Then I tried to implement it and it works well only if the user has signed in before thus making root view the FeedCollectionController if I sign out or delete the app, the app opens and closes everytime you try to open it never entering the app. How can I auto-login the user if the keychain is on their iOS and send them to the sign in view if there isn't a keychain?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
FirebaseApp.configure()
let userDefaults = UserDefaults.standard
if userDefaults.value(forKey: "appFirstTimeOpend") == nil {
userDefaults.setValue("1strun", forKey: "appFirstTimeOpend")
userDefaults.synchronize()
do{
try Auth.auth().signOut()
}catch{
ProgressHUD.showError()
}
window?.rootViewController = UINavigationController(rootViewController: SignInViewController())
}else {
let VC = FeedCollectionController(collectionViewLayout: UICollectionViewFlowLayout())
let navController = UINavigationController(rootViewController: VC)
window?.rootViewController = navController
}
return true
}