Skip to content

Commit 877ffe3

Browse files
authored
fix(ios): catch exceptions in open url (#1481)
1 parent 12ca1a9 commit 877ffe3

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed
Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
1-
#if canImport(ExpoModulesCore)
1+
#if canImport(ExpoModulesCore)
22
import ExpoModulesCore
33
import GoogleSignIn
44

55
public class GoogleSignInAppDelegate: ExpoAppDelegateSubscriber {
6-
public func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
6+
private func handleSignInURL(_ url: URL) throws -> Bool {
7+
// marked as `throws` to make compiler warning go away
78
return GIDSignIn.sharedInstance.handle(url)
89
}
10+
11+
public func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
12+
do {
13+
// As documented here:
14+
// https://github.com/google/GoogleSignIn-iOS/issues/547#issuecomment-3658139632
15+
// added both to handle the bug and as a precaution.
16+
return try handleSignInURL(url)
17+
} catch {
18+
NSLog("[RNGoogleSignIn] Failed to handle sign-in URL: %@", String(describing: error))
19+
return false
20+
}
21+
}
922
}
1023
#endif

0 commit comments

Comments
 (0)