diff --git a/packages/google_sign_in/google_sign_in/CHANGELOG.md b/packages/google_sign_in/google_sign_in/CHANGELOG.md index 429b07b47472..4e8ed80cba9c 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 @@ +## 5.0.2 + +* Fix flutter/flutter#48602 iOS flow shows account selection, if user is signed in to Google on the device. + ## 5.0.1 * Update platforms `init` function to prioritize `clientId` property when available; 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 757578bb3a50..578f64d5a41c 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 @@ -88,7 +88,11 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result [GIDSignIn sharedInstance].serverClientID = plist[kServerClientIdKey]; [GIDSignIn sharedInstance].scopes = call.arguments[@"scopes"]; - [GIDSignIn sharedInstance].hostedDomain = call.arguments[@"hostedDomain"]; + if (call.arguments[@"hostedDomain"] == [NSNull null]) { + [GIDSignIn sharedInstance].hostedDomain = nil; + } else { + [GIDSignIn sharedInstance].hostedDomain = call.arguments[@"hostedDomain"]; + } result(nil); } else { result([FlutterError errorWithCode:@"missing-config" diff --git a/packages/google_sign_in/google_sign_in/ios/Tests/GoogleSignInPluginTest.m b/packages/google_sign_in/google_sign_in/ios/Tests/GoogleSignInPluginTest.m index adbf61326c8d..0affe69280c0 100644 --- a/packages/google_sign_in/google_sign_in/ios/Tests/GoogleSignInPluginTest.m +++ b/packages/google_sign_in/google_sign_in/ios/Tests/GoogleSignInPluginTest.m @@ -153,4 +153,22 @@ - (void)testRequestScopesReturnsTrueIfGranted { XCTAssertTrue([result boolValue]); } +- (void)testHostedDomainIfMissed { + FlutterMethodCall *methodCall = + [FlutterMethodCall methodCallWithMethodName:@"init" + arguments:@{ + @"signInOption" : @"SignInOption.standard", + @"hostedDomain" : [NSNull null], + }]; + + XCTestExpectation *expectation = + [self expectationWithDescription:@"expect hostedDomain equals nil"]; + [self.plugin handleMethodCall:methodCall + result:^(id r) { + [expectation fulfill]; + }]; + [self waitForExpectations:@[ expectation ] timeout:5]; + XCTAssertTrue([self.mockSharedInstance.hostedDomain == nil]); +} + @end diff --git a/packages/google_sign_in/google_sign_in/pubspec.yaml b/packages/google_sign_in/google_sign_in/pubspec.yaml index 1184d0f9af25..edcd6e8f8017 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: 5.0.1 +version: 5.0.2 flutter: plugin: