From 6631da6b6b165a0c1e3260d744df1d60f3c7abe0 Mon Sep 17 00:00:00 2001 From: Guillaume Bernos Date: Thu, 8 Dec 2022 13:58:39 +0100 Subject: [PATCH] feat(auth): improve error message when user cancels a sign in with a provider (#10060) * feat(auth): improve error message when user cancels a sign in with a provider * feat: formatting --- .../ios/Classes/FLTFirebaseAuthPlugin.m | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/packages/firebase_auth/firebase_auth/ios/Classes/FLTFirebaseAuthPlugin.m b/packages/firebase_auth/firebase_auth/ios/Classes/FLTFirebaseAuthPlugin.m index fe9a2be5462e..3545a1d6fd8d 100644 --- a/packages/firebase_auth/firebase_auth/ios/Classes/FLTFirebaseAuthPlugin.m +++ b/packages/firebase_auth/firebase_auth/ios/Classes/FLTFirebaseAuthPlugin.m @@ -622,7 +622,33 @@ - (void)authorizationController:(ASAuthorizationController *)controller - (void)authorizationController:(ASAuthorizationController *)controller didCompleteWithError:(NSError *)error API_AVAILABLE(macos(10.15), ios(13.0)) { NSLog(@"Sign in with Apple errored: %@", error); - self.appleResult.error(nil, nil, nil, error); + switch (error.code) { + case ASAuthorizationErrorCanceled: + self.appleResult.error(@"canceled", @"The user canceled the authorization attempt.", nil, + error); + break; + + case ASAuthorizationErrorInvalidResponse: + self.appleResult.error(@"invalid-response", + @"The authorization request received an invalid response.", nil, + error); + break; + + case ASAuthorizationErrorNotHandled: + self.appleResult.error(@"not-handled", @"The authorization request wasn’t handled.", nil, + error); + break; + + case ASAuthorizationErrorFailed: + self.appleResult.error(@"failed", @"The authorization attempt failed.", nil, error); + break; + + case ASAuthorizationErrorUnknown: + default: + self.appleResult.error(nil, nil, nil, error); + break; + } + self.appleResult = nil; } - (void)signInWithProvider:(id)arguments