Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Review edits
  • Loading branch information
jmagman committed May 18, 2022
commit 3589229fbd5f041a544ff286b1196ff8bf4790e9
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,18 @@

@interface FLTGoogleSignInPlugin ()

// Configuration wrapping Google Cloud Console, Google Apps, OpenID,
// and other initialization metadata.
@property(strong) GIDConfiguration *configuration;

// Permissions requested during at sign in "init" method call
// unioned with scopes requested later with incremental authorization
// "requestScopes" method call.
// The "email" and "profile" base scopes are always implicitly requested.
@property(copy) NSSet<NSString *> *requestedScopes;

// Instance used to manage Google Sign In authentication including
// sign in, sign out, and requesting additional scopes.
@property(strong, readonly) GIDSignIn *signIn;

// Redeclared as not a designated initializer.
Expand Down Expand Up @@ -80,8 +90,8 @@ - (instancetype)initWithSignIn:(GIDSignIn *)signIn {
- (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result {
if ([call.method isEqualToString:@"init"]) {
GIDConfiguration *configuration =
[self configurationClientIdArgument:call.arguments[@"clientId"]
hostedDomainArgument:call.arguments[@"hostedDomain"]];
[self configurationWithClientIdArgument:call.arguments[@"clientId"]
hostedDomainArgument:call.arguments[@"hostedDomain"]];
if (configuration != nil) {
if ([call.arguments[@"scopes"] isKindOfClass:[NSArray class]]) {
self.requestedScopes = [NSSet setWithArray:call.arguments[@"scopes"]];
Expand All @@ -101,8 +111,9 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
result(@([self.signIn hasPreviousSignIn]));
} else if ([call.method isEqualToString:@"signIn"]) {
@try {
GIDConfiguration *configuration =
self.configuration ?: [self configurationClientIdArgument:nil hostedDomainArgument:nil];
GIDConfiguration *configuration = self.configuration
?: [self configurationWithClientIdArgument:nil
hostedDomainArgument:nil];
[self.signIn signInWithConfiguration:configuration
presentingViewController:[self topViewController]
hint:nil
Expand Down Expand Up @@ -188,8 +199,8 @@ - (void)signIn:(GIDSignIn *)signIn dismissViewController:(UIViewController *)vie
#pragma mark - private methods

/// @return @c nil if GoogleService-Info.plist not found.
- (GIDConfiguration *)configurationClientIdArgument:(id)clientIDArg
hostedDomainArgument:(id)hostedDomainArg {
- (GIDConfiguration *)configurationWithClientIdArgument:(id)clientIDArg
hostedDomainArgument:(id)hostedDomainArg {
NSString *plistPath = [NSBundle.mainBundle pathForResource:@"GoogleService-Info" ofType:@"plist"];
if (plistPath == nil) {
return nil;
Expand Down Expand Up @@ -219,8 +230,7 @@ - (void)didSignInForUser:(GIDGoogleUser *)user
} else {
NSURL *photoUrl;
if (user.profile.hasImage) {
// Placeholder that will be replaced by on the Dart side based on screen
// size
// Placeholder that will be replaced by on the Dart side based on screen size.
photoUrl = [user.profile imageURLWithDimension:1337];
}
[self respondWithAccount:@{
Expand Down