From d0142df6ae7bb399429da779311497e19b823499 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Thu, 15 Feb 2024 15:03:08 -0500 Subject: [PATCH 1/2] [google_sign_in] Clean up pre-Pigeon code Internal native helper code was still using `id` arguments, doing type checking, and handling `NSNull`, none of which is relevant now that the calling code has been converted to Pigeon and is already strongly typed as `NSString`. --- .../google_sign_in_ios/CHANGELOG.md | 3 +- .../darwin/Classes/FLTGoogleSignInPlugin.m | 43 +++++++------------ .../google_sign_in_ios/pubspec.yaml | 2 +- 3 files changed, 19 insertions(+), 29 deletions(-) diff --git a/packages/google_sign_in/google_sign_in_ios/CHANGELOG.md b/packages/google_sign_in/google_sign_in_ios/CHANGELOG.md index 7126a66e6787..5d5716e1715d 100644 --- a/packages/google_sign_in/google_sign_in_ios/CHANGELOG.md +++ b/packages/google_sign_in/google_sign_in_ios/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 5.7.4 +* Improves type handling in Objective-C code. * Updates minimum iOS version to 12.0 and minimum Flutter version to 3.16.6. ## 5.7.3 diff --git a/packages/google_sign_in/google_sign_in_ios/darwin/Classes/FLTGoogleSignInPlugin.m b/packages/google_sign_in/google_sign_in_ios/darwin/Classes/FLTGoogleSignInPlugin.m index 2f7e558ec202..7ae9d8fac5e6 100644 --- a/packages/google_sign_in/google_sign_in_ios/darwin/Classes/FLTGoogleSignInPlugin.m +++ b/packages/google_sign_in/google_sign_in_ios/darwin/Classes/FLTGoogleSignInPlugin.m @@ -111,9 +111,9 @@ - (BOOL)handleOpenURLs:(NSArray *)urls { - (void)initializeSignInWithParameters:(nonnull FSIInitParams *)params error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { - GIDConfiguration *configuration = [self configurationWithClientIdArgument:params.clientId - serverClientIdArgument:params.serverClientId - hostedDomainArgument:params.hostedDomain]; + GIDConfiguration *configuration = [self configurationWithClientIdentifier:params.clientId + serverClientIdentifier:params.serverClientId + hostedDomain:params.hostedDomain]; self.requestedScopes = [NSSet setWithArray:params.scopes]; if (configuration != nil) { self.configuration = configuration; @@ -141,9 +141,9 @@ - (void)signInWithCompletion:(nonnull void (^)(FSIUserData *_Nullable, // If neither are available, do not set the configuration - GIDSignIn will automatically use // settings from the Info.plist (which is the recommended method). if (!self.configuration && self.googleServiceProperties) { - self.configuration = [self configurationWithClientIdArgument:nil - serverClientIdArgument:nil - hostedDomainArgument:nil]; + self.configuration = [self configurationWithClientIdentifier:nil + serverClientIdentifier:nil + hostedDomain:nil]; } if (self.configuration) { self.signIn.configuration = self.configuration; @@ -270,30 +270,19 @@ - (void)addScopes:(NSArray *)scopes #endif } -/// @return @c nil if GoogleService-Info.plist not found and clientId is not provided. -- (GIDConfiguration *)configurationWithClientIdArgument:(id)clientIDArg - serverClientIdArgument:(id)serverClientIDArg - hostedDomainArgument:(id)hostedDomainArg { - NSString *clientID; - BOOL hasDynamicClientId = [clientIDArg isKindOfClass:[NSString class]]; - if (hasDynamicClientId) { - clientID = clientIDArg; - } else if (self.googleServiceProperties) { - clientID = self.googleServiceProperties[kClientIdKey]; - } else { - // We couldn't resolve a clientId, without which we cannot create a GIDConfiguration. +/// @return @c nil if GoogleService-Info.plist not found and runtimeClientIdentifier is not +/// provided. +- (GIDConfiguration *)configurationWithClientIdentifier:(NSString *)runtimeClientIdentifier + serverClientIdentifier:(NSString *)runtimeServerClientIdentifier + hostedDomain:(id)hostedDomain { + NSString *clientID = runtimeClientIdentifier ?: self.googleServiceProperties[kClientIdKey]; + if (!clientID) { + // Creating a GIDConfiguration requires a client identifier. return nil; } + NSString *serverClientID = + runtimeServerClientIdentifier ?: self.googleServiceProperties[kServerClientIdKey]; - BOOL hasDynamicServerClientId = [serverClientIDArg isKindOfClass:[NSString class]]; - NSString *serverClientID = hasDynamicServerClientId - ? serverClientIDArg - : self.googleServiceProperties[kServerClientIdKey]; - - NSString *hostedDomain = nil; - if (hostedDomainArg != [NSNull null]) { - hostedDomain = hostedDomainArg; - } return [[GIDConfiguration alloc] initWithClientID:clientID serverClientID:serverClientID hostedDomain:hostedDomain diff --git a/packages/google_sign_in/google_sign_in_ios/pubspec.yaml b/packages/google_sign_in/google_sign_in_ios/pubspec.yaml index 1e5044379f51..22c153723756 100644 --- a/packages/google_sign_in/google_sign_in_ios/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_ios/pubspec.yaml @@ -2,7 +2,7 @@ name: google_sign_in_ios description: iOS implementation of the google_sign_in plugin. repository: https://github.com/flutter/packages/tree/main/packages/google_sign_in/google_sign_in_ios issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22 -version: 5.7.3 +version: 5.7.4 environment: sdk: ^3.2.3 From 73652962846906ddb4f5cc9a95c26b4556c9565a Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Thu, 15 Feb 2024 15:23:42 -0500 Subject: [PATCH 2/2] Missed type --- .../google_sign_in_ios/darwin/Classes/FLTGoogleSignInPlugin.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/google_sign_in/google_sign_in_ios/darwin/Classes/FLTGoogleSignInPlugin.m b/packages/google_sign_in/google_sign_in_ios/darwin/Classes/FLTGoogleSignInPlugin.m index 7ae9d8fac5e6..d7a5cd85303c 100644 --- a/packages/google_sign_in/google_sign_in_ios/darwin/Classes/FLTGoogleSignInPlugin.m +++ b/packages/google_sign_in/google_sign_in_ios/darwin/Classes/FLTGoogleSignInPlugin.m @@ -274,7 +274,7 @@ - (void)addScopes:(NSArray *)scopes /// provided. - (GIDConfiguration *)configurationWithClientIdentifier:(NSString *)runtimeClientIdentifier serverClientIdentifier:(NSString *)runtimeServerClientIdentifier - hostedDomain:(id)hostedDomain { + hostedDomain:(NSString *)hostedDomain { NSString *clientID = runtimeClientIdentifier ?: self.googleServiceProperties[kClientIdKey]; if (!clientID) { // Creating a GIDConfiguration requires a client identifier.