[google_sign_in] Fix "pick account" on iOS (#3805)
diff --git a/packages/google_sign_in/google_sign_in/CHANGELOG.md b/packages/google_sign_in/google_sign_in/CHANGELOG.md
index 429b07b..4e8ed80 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 757578b..578f64d 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 @@
[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 adbf613..0affe69 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 @@
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 1184d0f..edcd6e8 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 @@
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: