diff --git a/nirvana-ios.xcodeproj/project.pbxproj b/nirvana-ios.xcodeproj/project.pbxproj index 3125fc3..8756027 100644 --- a/nirvana-ios.xcodeproj/project.pbxproj +++ b/nirvana-ios.xcodeproj/project.pbxproj @@ -29,7 +29,6 @@ 89288EC7276756DF00E962C4 /* FirebaseDatabase in Frameworks */ = {isa = PBXBuildFile; productRef = 89288EC6276756DF00E962C4 /* FirebaseDatabase */; }; 89288EC9276756DF00E962C4 /* FirebaseStorage in Frameworks */ = {isa = PBXBuildFile; productRef = 89288EC8276756DF00E962C4 /* FirebaseStorage */; }; 89288ECB27675B9F00E962C4 /* OnboardingTemplateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89288ECA27675B9F00E962C4 /* OnboardingTemplateView.swift */; }; - 89AD556F276D63E4001658E0 /* PopupView in Frameworks */ = {isa = PBXBuildFile; productRef = 89AD556E276D63E4001658E0 /* PopupView */; }; 89B46E71276893E200B74255 /* AuthSessionStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89B46E70276893E200B74255 /* AuthSessionStore.swift */; }; 89BCABE2276B3CB0009E9B10 /* NavigationStack in Frameworks */ = {isa = PBXBuildFile; productRef = 89BCABE1276B3CB0009E9B10 /* NavigationStack */; }; 89BCABE5276B3D58009E9B10 /* InnerCircleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89BCABE4276B3D58009E9B10 /* InnerCircleView.swift */; }; @@ -97,7 +96,6 @@ buildActionMask = 2147483647; files = ( 89288EC3276756DF00E962C4 /* FirebaseAnalytics in Frameworks */, - 89AD556F276D63E4001658E0 /* PopupView in Frameworks */, 89BCABE2276B3CB0009E9B10 /* NavigationStack in Frameworks */, 89288EC5276756DF00E962C4 /* FirebaseAuth in Frameworks */, 89288EC7276756DF00E962C4 /* FirebaseDatabase in Frameworks */, @@ -319,7 +317,6 @@ 89288EC8276756DF00E962C4 /* FirebaseStorage */, 89F1386F2767F55F006680ED /* GoogleSignIn */, 89BCABE1276B3CB0009E9B10 /* NavigationStack */, - 89AD556E276D63E4001658E0 /* PopupView */, ); productName = "nirvana-ios"; productReference = 891A15DD27653A7000B26659 /* nirvana-ios.app */; @@ -353,7 +350,6 @@ 89288EC1276756DF00E962C4 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */, 89F1386E2767F55F006680ED /* XCRemoteSwiftPackageReference "GoogleSignIn-iOS" */, 89BCABE0276B3CB0009E9B10 /* XCRemoteSwiftPackageReference "swiftui-navigation-stack" */, - 89AD556D276D63E4001658E0 /* XCRemoteSwiftPackageReference "PopupView" */, ); productRefGroup = 891A15DE27653A7000B26659 /* Products */; projectDirPath = ""; @@ -634,14 +630,6 @@ minimumVersion = 8.0.0; }; }; - 89AD556D276D63E4001658E0 /* XCRemoteSwiftPackageReference "PopupView" */ = { - isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/exyte/PopupView"; - requirement = { - kind = upToNextMajorVersion; - minimumVersion = 1.0.0; - }; - }; 89BCABE0276B3CB0009E9B10 /* XCRemoteSwiftPackageReference "swiftui-navigation-stack" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/matteopuc/swiftui-navigation-stack.git"; @@ -681,11 +669,6 @@ package = 89288EC1276756DF00E962C4 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */; productName = FirebaseStorage; }; - 89AD556E276D63E4001658E0 /* PopupView */ = { - isa = XCSwiftPackageProductDependency; - package = 89AD556D276D63E4001658E0 /* XCRemoteSwiftPackageReference "PopupView" */; - productName = PopupView; - }; 89BCABE1276B3CB0009E9B10 /* NavigationStack */ = { isa = XCSwiftPackageProductDependency; package = 89BCABE0276B3CB0009E9B10 /* XCRemoteSwiftPackageReference "swiftui-navigation-stack" */; diff --git a/nirvana-ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/nirvana-ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 26076d0..9d5cafb 100644 --- a/nirvana-ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/nirvana-ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -118,15 +118,6 @@ "version": "2.30908.0" } }, - { - "package": "PopupView", - "repositoryURL": "https://github.com/exyte/PopupView", - "state": { - "branch": null, - "revision": "4cf8c01473282b3711e6780bd78ef81add97f6e2", - "version": "1.0.3" - } - }, { "package": "Promises", "repositoryURL": "https://github.com/google/promises.git", diff --git a/nirvana-ios/Info.plist b/nirvana-ios/Info.plist index 7082d13..8f00951 100644 --- a/nirvana-ios/Info.plist +++ b/nirvana-ios/Info.plist @@ -19,5 +19,7 @@ Satisfy-Regular.ttf + UIUserInterfaceStyle + Light diff --git a/nirvana-ios/Services/AuthSessionStore.swift b/nirvana-ios/Services/AuthSessionStore.swift index c710f96..001f210 100644 --- a/nirvana-ios/Services/AuthSessionStore.swift +++ b/nirvana-ios/Services/AuthSessionStore.swift @@ -44,6 +44,7 @@ final class AuthSessionStore: ObservableObject, SessionStore { self.setupAuthListen() } + // MARK: OLD for google sign in with link func signInOrCreateUser() { if GIDSignIn.sharedInstance.currentUser == nil { guard @@ -76,6 +77,7 @@ final class AuthSessionStore: ObservableObject, SessionStore { } } + // MARK: OLD for google sign in with link func firebaseAuth(withCredentials authCred: AuthCredential) { Auth.auth().signIn(with: authCred) { result, error in if error != nil { @@ -113,12 +115,14 @@ final class AuthSessionStore: ObservableObject, SessionStore { self.handler = Auth.auth().addStateDidChangeListener { (auth, user) in print("auth listener activated") + // get the user from the auth table in firebase auth if let user = user { // if we have a user, create a new user model - print("Got user: \(user.displayName!)") - self.user = User( - _uid: user.uid, _email: user.email, _displayName: user.displayName, _profilePic: user.photoURL, _phoneNumber: user.phoneNumber) + print("Got user: \(user.uid)") + print("phone number: \(user.phoneNumber!)") + // TODO: go to firestore and get full user document for the current authenticated user + // and have this in environment for all pages to access without having to fetch all the time self.sessionState = .isAuthenticated } else { // if we don't have a user, set our session to nil diff --git a/nirvana-ios/Views/HomeView/InnerCircle/InnerCircleView.swift b/nirvana-ios/Views/HomeView/InnerCircle/InnerCircleView.swift index 5808d08..3a35207 100644 --- a/nirvana-ios/Views/HomeView/InnerCircle/InnerCircleView.swift +++ b/nirvana-ios/Views/HomeView/InnerCircle/InnerCircleView.swift @@ -216,7 +216,6 @@ struct InnerCircleView: View { } .scaleEffect(scale) .padding(scale * 5) - } // geometry reader .offset( x: honeycombOffSetX(value), diff --git a/nirvana-ios/Views/PhoneVerification/PhoneVerificationView.swift b/nirvana-ios/Views/PhoneVerification/PhoneVerificationView.swift index d6a6b33..c8bde45 100644 --- a/nirvana-ios/Views/PhoneVerification/PhoneVerificationView.swift +++ b/nirvana-ios/Views/PhoneVerification/PhoneVerificationView.swift @@ -8,8 +8,6 @@ import SwiftUI import NavigationStack import Combine -// TODO: maybe this is useless and just do my own toasts and alerts -import PopupView import Firebase import FirebaseAuth @@ -169,7 +167,7 @@ struct PhoneVerificationCodeView: View { print("verify code") // do auth stuff - + // get it from the previous screen but from storage let verificationID = UserDefaults.standard.string(forKey: "authVerificationID") @@ -191,14 +189,21 @@ struct PhoneVerificationCodeView: View { return } + //setting in key storage UserDefaults.standard.set(true, forKey: "authVerificationID") + //TODO: is the auth listener going to find that this person signed in? idk test it + + // firebase either created a new user or is giving back an existing user's id + let userId = res?.user.uid + let userPhoneNumber = res?.user.phoneNumber + print("user id that was authenticated is: \(userId)") + print("user id that was authenticated is: \(userPhoneNumber)") + + + // then sending to next page + self.navigationStack.push(PhoneVerificationCodeView()) // verify code page } - - // then async send to next page - self.navigationStack.push(PhoneVerificationCodeView()) // verify code page - - } label: { Text("Send Verification") .bold() diff --git a/nirvana-ios/nirvana_iosApp.swift b/nirvana-ios/nirvana_iosApp.swift index bb80e4d..482bcf8 100644 --- a/nirvana-ios/nirvana_iosApp.swift +++ b/nirvana-ios/nirvana_iosApp.swift @@ -13,22 +13,61 @@ import GoogleSignIn struct nirvana_iosApp: App { @StateObject var authSessionStore: AuthSessionStore = AuthSessionStore() - @UIApplicationDelegateAdaptor private var appDelegate: AppDelegate - + @UIApplicationDelegateAdaptor(AppDelegate.self) var delegate var body: some Scene { WindowGroup { - ContentView().environmentObject(authSessionStore) + ContentView() + .environmentObject(authSessionStore) + .onOpenURL { url in + print("Received URL: \(url)") + Auth.auth().canHandle(url) // <- just for information purposes + } } } } class AppDelegate: NSObject, UIApplicationDelegate { - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { - FirebaseApp.configure() - return true - } + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { + FirebaseApp.configure() + return true + } + func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { + print("\(#function)") + Auth.auth().setAPNSToken(deviceToken, type: .sandbox) + } + + func application(_ application: UIApplication, didReceiveRemoteNotification notification: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { + print("\(#function)") + if Auth.auth().canHandleNotification(notification) { + completionHandler(.noData) + return + } + } + + // For iOS 9+ func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool { - return GIDSignIn.sharedInstance.handle(url) + // MARK: turned off google sign in link in for phone below + // return GIDSignIn.sharedInstance.handle(url) + + // if the user can be handled by google auth, then it will do so + if Auth.auth().canHandle(url) { + return true + } + // URL not auth related, developer should handle it. + + return true + } + + // For iOS 8- + func application(_ application: UIApplication, + open url: URL, + sourceApplication: String?, + annotation: Any) -> Bool { + if Auth.auth().canHandle(url) { + return true + } + // URL not auth related, developer should handle it. + return true } }