Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[google_sign_in] Fix "pick account" on iOS #3805

Merged
merged 3 commits into from
Apr 13, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/google_sign_in/google_sign_in/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 5.1.0

* 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was missed during a change in how we run tests, so was not actually being compiled and run. In trying to fix it I found that:
a) it doesn't compile, because of this line, and
b) when that's fixed, other unit tests crash (presumably because calling init changes global state)

I'm going to have to remove this test to get the file running again; if you could submit a PR with a version of the test that compiles, and runs successfully in the context of the whole test suite, that would be great.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

@end
2 changes: 1 addition & 1 deletion packages/google_sign_in/google_sign_in/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.1.0

flutter:
plugin:
Expand Down