Open source CapCut alternative.
TypeScript
fix(ios): Google sign-in checks its callback scheme first
David Lea006d33a3373
diff --git a/apps/ios/Donkey/Controllers/AuthController.swift b/apps/ios/Donkey/Controllers/AuthController.swiftindex 13dae224..f5fc4fd2 100644--- a/apps/ios/Donkey/Controllers/AuthController.swift+++ b/apps/ios/Donkey/Controllers/AuthController.swift@@ -160,7 +160,7 @@ final class AuthController: NSObject, AuthServicing {// MARK: Googleprivate func googleIdToken() async throws -> String {- guard !AuthBackend.googleClientID.isEmpty else {+ guard !AuthBackend.googleClientID.isEmpty, Self.hasGoogleCallbackScheme() else {throw AuthError.googleNotConfigured}guard let presenter = Self.presentingViewController() else {@@ -174,6 +174,16 @@ final class AuthController: NSObject, AuthServicing {return token}+ /// The Google SDK raises an uncatchable exception when the app lacks the+ /// URL scheme it redirects back on (the client id with its dot-segments+ /// reversed), so verify the registration before starting the flow.+ private static func hasGoogleCallbackScheme() -> Bool {+ let reversed = AuthBackend.googleClientID+ .split(separator: ".").reversed().joined(separator: ".")+ let types = Bundle.main.object(forInfoDictionaryKey: "CFBundleURLTypes") as? [[String: Any]] ?? []+ return types.contains { ($0["CFBundleURLSchemes"] as? [String] ?? []).contains(reversed) }+ }+private static func presentingViewController() -> UIViewController? {UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene }diff --git a/apps/ios/Donkey/DonkeyApp.swift b/apps/ios/Donkey/DonkeyApp.swiftindex 2be3ab38..9ba96922 100644--- a/apps/ios/Donkey/DonkeyApp.swift+++ b/apps/ios/Donkey/DonkeyApp.swift@@ -1,5 +1,6 @@import DonkeyKitModelsimport DonkeyKitUI+import GoogleSignInimport SwiftUI@main@@ -16,10 +17,11 @@ struct DonkeyApp: App {projects: wiring.projects,auth: wiring.auth) {- CameraPreviewView(session: wiring.cameraController.session) {+ CameraPreviewView(host: wiring.cameraController.previewView) {wiring.camera.toggleRecording()}}+ .onOpenURL { _ = GIDSignIn.sharedInstance.handle($0) }}}}@@ -49,9 +51,8 @@ final class AppWiring {cameraController.model = cameracamera.controller = cameraController- cameraController.onRecordingFinished = { [media, app] url, duration, thumbnail in+ cameraController.onRecordingFinished = { [media] url, duration, thumbnail inmedia.ingest(movieAt: url, duration: duration, thumbnail: thumbnail)- app.show(toast: "Saved to Library")}}}