Skip to content

Commit b548ae1

Browse files
authored
[google_sign_in] Fix "pick account" on iOS (flutter#3805)
1 parent f34add3 commit b548ae1

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

packages/google_sign_in/google_sign_in/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 5.0.2
2+
3+
* Fix flutter/flutter#48602 iOS flow shows account selection, if user is signed in to Google on the device.
4+
15
## 5.0.1
26

37
* Update platforms `init` function to prioritize `clientId` property when available;

packages/google_sign_in/google_sign_in/ios/Classes/FLTGoogleSignInPlugin.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,11 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
8888

8989
[GIDSignIn sharedInstance].serverClientID = plist[kServerClientIdKey];
9090
[GIDSignIn sharedInstance].scopes = call.arguments[@"scopes"];
91-
[GIDSignIn sharedInstance].hostedDomain = call.arguments[@"hostedDomain"];
91+
if (call.arguments[@"hostedDomain"] == [NSNull null]) {
92+
[GIDSignIn sharedInstance].hostedDomain = nil;
93+
} else {
94+
[GIDSignIn sharedInstance].hostedDomain = call.arguments[@"hostedDomain"];
95+
}
9296
result(nil);
9397
} else {
9498
result([FlutterError errorWithCode:@"missing-config"

packages/google_sign_in/google_sign_in/ios/Tests/GoogleSignInPluginTest.m

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,22 @@ - (void)testRequestScopesReturnsTrueIfGranted {
153153
XCTAssertTrue([result boolValue]);
154154
}
155155

156+
- (void)testHostedDomainIfMissed {
157+
FlutterMethodCall *methodCall =
158+
[FlutterMethodCall methodCallWithMethodName:@"init"
159+
arguments:@{
160+
@"signInOption" : @"SignInOption.standard",
161+
@"hostedDomain" : [NSNull null],
162+
}];
163+
164+
XCTestExpectation *expectation =
165+
[self expectationWithDescription:@"expect hostedDomain equals nil"];
166+
[self.plugin handleMethodCall:methodCall
167+
result:^(id r) {
168+
[expectation fulfill];
169+
}];
170+
[self waitForExpectations:@[ expectation ] timeout:5];
171+
XCTAssertTrue([self.mockSharedInstance.hostedDomain == nil]);
172+
}
173+
156174
@end

packages/google_sign_in/google_sign_in/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: google_sign_in
22
description: Flutter plugin for Google Sign-In, a secure authentication system
33
for signing in with a Google account on Android and iOS.
44
homepage: https://github.com/flutter/plugins/tree/master/packages/google_sign_in/google_sign_in
5-
version: 5.0.1
5+
version: 5.0.2
66

77
flutter:
88
plugin:

0 commit comments

Comments
 (0)