working auth handler and listener and successfuly changing auth and all

This commit is contained in:
talksik
2021-12-14 14:56:58 -08:00
parent 60723a5118
commit d8070b30f3
2 changed files with 16 additions and 7 deletions
+6 -1
View File
@@ -39,6 +39,8 @@ final class AuthSessionStore: ObservableObject, SessionStore {
let clientID = FirebaseApp.app()?.options.clientID
self.GIDconfig = GIDConfiguration(clientID: clientID!)
print(clientID)
self.setupAuthListen()
}
@@ -113,12 +115,15 @@ final class AuthSessionStore: ObservableObject, SessionStore {
if let user = user {
// if we have a user, create a new user model
print("Got user: \(user)")
print("Got user: \(user.displayName!)")
self.user = User(
_uid: user.uid, _email: user.email, _displayName: user.displayName, _profilePic: user.photoURL, _phoneNumber: user.phoneNumber)
self.sessionState = .isAuthenticated
} else {
// if we don't have a user, set our session to nil
self.user = nil
self.sessionState = .isLoggedOut
}
}
}
+10 -6
View File
@@ -13,9 +13,8 @@ import GoogleSignIn
struct nirvana_iosApp: App {
@StateObject var authSessionStore: AuthSessionStore = AuthSessionStore()
init() {
self.setupAuth()
}
@UIApplicationDelegateAdaptor private var appDelegate: AppDelegate
var body: some Scene {
WindowGroup {
@@ -24,8 +23,13 @@ struct nirvana_iosApp: App {
}
}
extension nirvana_iosApp {
private func setupAuth() {
FirebaseApp.configure()
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
FirebaseApp.configure()
return true
}
func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool {
return GIDSignIn.sharedInstance.handle(url)
}
}