diff --git a/packages/google_sign_in/google_sign_in/CHANGELOG.md b/packages/google_sign_in/google_sign_in/CHANGELOG.md index 19f7f8940238..5754ef407879 100644 --- a/packages/google_sign_in/google_sign_in/CHANGELOG.md +++ b/packages/google_sign_in/google_sign_in/CHANGELOG.md @@ -1,3 +1,7 @@ +## 4.1.2 + +* Added a new error code `network_error`, and return it when a network error occurred. + ## 4.1.1 * Support passing `clientId` to the web plugin programmatically. diff --git a/packages/google_sign_in/google_sign_in/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java b/packages/google_sign_in/google_sign_in/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java index d2fc260c7b1c..6c9bedde1038 100755 --- a/packages/google_sign_in/google_sign_in/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java +++ b/packages/google_sign_in/google_sign_in/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java @@ -173,6 +173,7 @@ public static final class Delegate implements IDelegate, PluginRegistry.Activity // These error codes must match with ones declared on iOS and Dart sides. private static final String ERROR_REASON_SIGN_IN_CANCELED = "sign_in_canceled"; private static final String ERROR_REASON_SIGN_IN_REQUIRED = "sign_in_required"; + private static final String ERROR_REASON_NETWORK_ERROR = "network_error"; private static final String ERROR_REASON_SIGN_IN_FAILED = "sign_in_failed"; private static final String ERROR_FAILURE_TO_RECOVER_AUTH = "failed_to_recover_auth"; private static final String ERROR_USER_RECOVERABLE_AUTH = "user_recoverable_auth"; @@ -372,6 +373,8 @@ private String errorCodeForStatus(int statusCode) { return ERROR_REASON_SIGN_IN_CANCELED; } else if (statusCode == CommonStatusCodes.SIGN_IN_REQUIRED) { return ERROR_REASON_SIGN_IN_REQUIRED; + } else if (statusCode == CommonStatusCodes.NETWORK_ERROR) { + return ERROR_REASON_NETWORK_ERROR; } else { return ERROR_REASON_SIGN_IN_FAILED; } diff --git a/packages/google_sign_in/google_sign_in/ios/Classes/FLTGoogleSignInPlugin.m b/packages/google_sign_in/google_sign_in/ios/Classes/FLTGoogleSignInPlugin.m index 559997f9d621..dff3481ec16f 100644 --- a/packages/google_sign_in/google_sign_in/ios/Classes/FLTGoogleSignInPlugin.m +++ b/packages/google_sign_in/google_sign_in/ios/Classes/FLTGoogleSignInPlugin.m @@ -13,6 +13,7 @@ // These error codes must match with ones declared on Android and Dart sides. static NSString *const kErrorReasonSignInRequired = @"sign_in_required"; static NSString *const kErrorReasonSignInCanceled = @"sign_in_canceled"; +static NSString *const kErrorReasonNetworkError = @"network_error"; static NSString *const kErrorReasonSignInFailed = @"sign_in_failed"; static FlutterError *getFlutterError(NSError *error) { @@ -21,6 +22,8 @@ errorCode = kErrorReasonSignInRequired; } else if (error.code == kGIDSignInErrorCodeCanceled) { errorCode = kErrorReasonSignInCanceled; + } else if ([error.domain isEqualToString:NSURLErrorDomain]) { + errorCode = kErrorReasonNetworkError; } else { errorCode = kErrorReasonSignInFailed; } diff --git a/packages/google_sign_in/google_sign_in/lib/google_sign_in.dart b/packages/google_sign_in/google_sign_in/lib/google_sign_in.dart index 0bd28faf5cf7..09753377ac76 100644 --- a/packages/google_sign_in/google_sign_in/lib/google_sign_in.dart +++ b/packages/google_sign_in/google_sign_in/lib/google_sign_in.dart @@ -195,6 +195,9 @@ class GoogleSignIn { /// user. static const String kSignInCanceledError = 'sign_in_canceled'; + /// Error code indicating network error. Retrying should resolve the problem. + static const String kNetworkError = 'network_error'; + /// Error code indicating that attempt to sign in failed. static const String kSignInFailedError = 'sign_in_failed'; @@ -314,8 +317,9 @@ class GoogleSignIn { /// /// When [suppressErrors] is set to `false` and an error occurred during sign in /// returned Future completes with [PlatformException] whose `code` can be - /// either [kSignInRequiredError] (when there is no authenticated user) or - /// [kSignInFailedError] (when an unknown error occurred). + /// one of [kSignInRequiredError] (when there is no authenticated user) , + /// [kNetworkError] (when a network error occurred) or [kSignInFailedError] + /// (when an unknown error occurred). Future signInSilently({ bool suppressErrors = true, }) async { diff --git a/packages/google_sign_in/google_sign_in/pubspec.yaml b/packages/google_sign_in/google_sign_in/pubspec.yaml index 02f8f63fd7a8..a5bd24178289 100644 --- a/packages/google_sign_in/google_sign_in/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in/pubspec.yaml @@ -2,7 +2,7 @@ name: google_sign_in description: Flutter plugin for Google Sign-In, a secure authentication system for signing in with a Google account on Android and iOS. homepage: https://github.com/flutter/plugins/tree/master/packages/google_sign_in/google_sign_in -version: 4.1.1 +version: 4.1.2 flutter: plugin: