Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/ios-google-signin-presenting-window.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/expo-google-signin': patch
---

Fix iOS Google sign-in failing with `GOOGLE_SIGN_IN_ERROR` in apps with more than one window or scene. The presenting view controller is now resolved from the key window of the foreground-active scene instead of an arbitrary window, so overlays such as splash screens or windows created by other modules no longer break the sign-in flow.
11 changes: 8 additions & 3 deletions packages/expo-google-signin/ios/ClerkGoogleSignInModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,19 @@ public class ClerkGoogleSignInModule: Module {
}

private func getPresentingViewController() -> UIViewController? {
guard let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let window = scene.windows.first,
let scenes = UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene }
let scene = scenes.first { $0.activationState == .foregroundActive }
?? scenes.first { $0.activationState == .foregroundInactive }
?? scenes.first
Comment thread
coderabbitai[bot] marked this conversation as resolved.

guard let window = scene?.windows.first(where: { $0.isKeyWindow && !$0.isHidden && $0.rootViewController != nil })
?? scene?.windows.first(where: { !$0.isHidden && $0.rootViewController != nil }),
let rootVC = window.rootViewController else {
return nil
}

var topVC = rootVC
while let presentedVC = topVC.presentedViewController {
while let presentedVC = topVC.presentedViewController, !presentedVC.isBeingDismissed {
topVC = presentedVC
}
return topVC
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Expand Down
Loading