From f34364f68d552ac98bd6335e5f021a640c2ebf83 Mon Sep 17 00:00:00 2001 From: Jude Kwashie Date: Thu, 2 Jul 2026 09:00:44 +0000 Subject: [PATCH 1/2] fix(auth, iOS): add detailed error handling for Apple authorization failures --- .../firebase_auth/FLTFirebaseAuthPlugin.m | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/packages/firebase_auth/firebase_auth/ios/firebase_auth/Sources/firebase_auth/FLTFirebaseAuthPlugin.m b/packages/firebase_auth/firebase_auth/ios/firebase_auth/Sources/firebase_auth/FLTFirebaseAuthPlugin.m index 606dda68176d..dce9bc87964b 100644 --- a/packages/firebase_auth/firebase_auth/ios/firebase_auth/Sources/firebase_auth/FLTFirebaseAuthPlugin.m +++ b/packages/firebase_auth/firebase_auth/ios/firebase_auth/Sources/firebase_auth/FLTFirebaseAuthPlugin.m @@ -219,6 +219,40 @@ + (FlutterError *)convertToFlutterError:(NSError *)error { return [FlutterError errorWithCode:code message:message details:additionalData]; } ++ (FlutterError *)convertAppleAuthorizationErrorToFlutterError:(NSError *)error { + NSString *message = @"An unknown error has occurred."; + if (error.localizedDescription.length > 0) { + message = error.localizedDescription; + } + + NSMutableDictionary *additionalData = [NSMutableDictionary dictionary]; + NSString *nativeErrorDomain = error.domain ?: @"unknown"; + NSNumber *nativeErrorCode = @((long)error.code); + + additionalData[@"nativeErrorDomain"] = nativeErrorDomain; + additionalData[@"nativeErrorCode"] = nativeErrorCode; + + NSError *underlyingError = error.userInfo[NSUnderlyingErrorKey]; + NSString *underlyingMessage = @""; + if (underlyingError != nil) { + NSString *underlyingErrorDomain = underlyingError.domain ?: @"unknown"; + NSNumber *underlyingErrorCode = @((long)underlyingError.code); + + additionalData[@"underlyingNativeErrorDomain"] = underlyingErrorDomain; + additionalData[@"underlyingNativeErrorCode"] = underlyingErrorCode; + + underlyingMessage = + [NSString stringWithFormat:@", Underlying: Domain=%@ Code=%ld", underlyingErrorDomain, + (long)underlyingError.code]; + } + + NSString *detailMessage = + [NSString stringWithFormat:@"%@ (Domain=%@ Code=%ld%@)", message, nativeErrorDomain, + (long)error.code, underlyingMessage]; + + return [FlutterError errorWithCode:@"unknown" message:detailMessage details:additionalData]; +} + + (id)getNSDictionaryFromAuthCredential:(FIRAuthCredential *)authCredential { if (authCredential == nil) { return [NSNull null]; @@ -532,7 +566,7 @@ - (void)authorizationController:(ASAuthorizationController *)controller case ASAuthorizationErrorUnknown: default: - completion(nil, [FLTFirebaseAuthPlugin convertToFlutterError:error]); + completion(nil, [FLTFirebaseAuthPlugin convertAppleAuthorizationErrorToFlutterError:error]); break; } } From 5a0c012d760f0a48be1f2e17bd422b2cb318c41b Mon Sep 17 00:00:00 2001 From: Jude Kwashie Date: Thu, 2 Jul 2026 10:00:34 +0000 Subject: [PATCH 2/2] fix(auth, iOS): correct error message formatting for Apple authorization failures --- .../firebase_auth/Sources/firebase_auth/FLTFirebaseAuthPlugin.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/firebase_auth/firebase_auth/ios/firebase_auth/Sources/firebase_auth/FLTFirebaseAuthPlugin.m b/packages/firebase_auth/firebase_auth/ios/firebase_auth/Sources/firebase_auth/FLTFirebaseAuthPlugin.m index dce9bc87964b..cd21c449fb2e 100644 --- a/packages/firebase_auth/firebase_auth/ios/firebase_auth/Sources/firebase_auth/FLTFirebaseAuthPlugin.m +++ b/packages/firebase_auth/firebase_auth/ios/firebase_auth/Sources/firebase_auth/FLTFirebaseAuthPlugin.m @@ -242,7 +242,7 @@ + (FlutterError *)convertAppleAuthorizationErrorToFlutterError:(NSError *)error additionalData[@"underlyingNativeErrorCode"] = underlyingErrorCode; underlyingMessage = - [NSString stringWithFormat:@", Underlying: Domain=%@ Code=%ld", underlyingErrorDomain, + [NSString stringWithFormat:@", Underlying Domain=%@ Code=%ld", underlyingErrorDomain, (long)underlyingError.code]; }