Skip to content

Commit

Permalink
feat: catch and print sign in crash when in debug mode (#1337)
Browse files Browse the repository at this point in the history
  • Loading branch information
vonovak committed Sep 20, 2024
1 parent 8316ebc commit a817cfc
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions ios/RNGoogleSignin.mm
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,22 @@ + (BOOL)requiresMainQueueSetup
reject:(RCTPromiseRejectBlock)reject)
{
dispatch_async(dispatch_get_main_queue(), ^{
UIViewController* presentingViewController = RCTPresentedViewController();
NSString* hint = options[@"loginHint"];
NSArray* scopes = self.scopes;

[GIDSignIn.sharedInstance signInWithPresentingViewController:presentingViewController hint:hint additionalScopes:scopes completion:^(GIDSignInResult * _Nullable signInResult, NSError * _Nullable error) {
[self handleCompletion:signInResult withError:error withResolver:resolve withRejector:reject fromCallsite:@"signIn"];
#if DEBUG
@try {
#endif
[GIDSignIn.sharedInstance signInWithPresentingViewController:RCTPresentedViewController() hint:hint additionalScopes:scopes completion:^(GIDSignInResult * _Nullable signInResult, NSError * _Nullable error) {
[self handleCompletion:signInResult withError:error withResolver:resolve withRejector:reject fromCallsite:@"signIn"];
}];
#if DEBUG
}
@catch (NSException *exception) {
NSString *errorMessage = [NSString stringWithFormat:@"Encountered an error when signing in (see more below). If the error is 'Your app is missing support for the following URL schemes...', follow the troubleshooting guide at https://react-native-google-signin.github.io/docs/troubleshooting#ios\n\n%@", exception.description];
reject(@"SIGN_IN_ERROR", errorMessage, nil);
}
#endif
});
}

Expand Down

0 comments on commit a817cfc

Please sign in to comment.