[google_sign_in] Fix deprecated API usage issue by upgrading CocoaPod to 5.0 (#2127)
* Fix Deprecated API Usage issue
* Update to 5.0 compatibility
diff --git a/packages/google_sign_in/CHANGELOG.md b/packages/google_sign_in/CHANGELOG.md
index a8f0d6a..300eba2 100644
--- a/packages/google_sign_in/CHANGELOG.md
+++ b/packages/google_sign_in/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 4.0.11
+
+* Update iOS CocoaPod dependency to 5.0 to fix deprecated API usage issue.
+
## 4.0.10
* Remove AndroidX warning.
diff --git a/packages/google_sign_in/ios/Classes/GoogleSignInPlugin.m b/packages/google_sign_in/ios/Classes/GoogleSignInPlugin.m
index 483bc5c..716eb36 100644
--- a/packages/google_sign_in/ios/Classes/GoogleSignInPlugin.m
+++ b/packages/google_sign_in/ios/Classes/GoogleSignInPlugin.m
@@ -29,7 +29,7 @@
details:error.localizedDescription];
}
-@interface FLTGoogleSignInPlugin () <GIDSignInDelegate, GIDSignInUIDelegate>
+@interface FLTGoogleSignInPlugin () <GIDSignInDelegate>
@end
@implementation FLTGoogleSignInPlugin {
@@ -49,7 +49,6 @@
self = [super init];
if (self) {
[GIDSignIn sharedInstance].delegate = self;
- [GIDSignIn sharedInstance].uiDelegate = self;
// On the iOS simulator, we get "Broken pipe" errors after sign-in for some
// unknown reason. We can avoid crashing the app by ignoring them.
@@ -84,11 +83,13 @@
}
} else if ([call.method isEqualToString:@"signInSilently"]) {
if ([self setAccountRequest:result]) {
- [[GIDSignIn sharedInstance] signInSilently];
+ [[GIDSignIn sharedInstance] restorePreviousSignIn];
}
} else if ([call.method isEqualToString:@"isSignedIn"]) {
- result(@([[GIDSignIn sharedInstance] hasAuthInKeychain]));
+ result(@([[GIDSignIn sharedInstance] hasPreviousSignIn]));
} else if ([call.method isEqualToString:@"signIn"]) {
+ [GIDSignIn sharedInstance].presentingViewController = [self topViewController];
+
if ([self setAccountRequest:result]) {
@try {
[[GIDSignIn sharedInstance] signIn];
@@ -135,10 +136,7 @@
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options {
NSString *sourceApplication = options[UIApplicationOpenURLOptionsSourceApplicationKey];
- id annotation = options[UIApplicationOpenURLOptionsAnnotationKey];
- return [[GIDSignIn sharedInstance] handleURL:url
- sourceApplication:sourceApplication
- annotation:annotation];
+ return [[GIDSignIn sharedInstance] handleURL:url];
}
#pragma mark - <GIDSignInUIDelegate> protocol
@@ -192,4 +190,36 @@
result(error != nil ? getFlutterError(error) : account);
}
+- (UIViewController *)topViewController {
+ return [self topViewControllerFromViewController:[UIApplication sharedApplication]
+ .keyWindow.rootViewController];
+}
+
+/**
+ * This method recursively iterate through the view hierarchy
+ * to return the top most view controller.
+ *
+ * It supports the following scenarios:
+ *
+ * - The view controller is presenting another view.
+ * - The view controller is a UINavigationController.
+ * - The view controller is a UITabBarController.
+ *
+ * @return The top most view controller.
+ */
+- (UIViewController *)topViewControllerFromViewController:(UIViewController *)viewController {
+ if ([viewController isKindOfClass:[UINavigationController class]]) {
+ UINavigationController *navigationController = (UINavigationController *)viewController;
+ return [self
+ topViewControllerFromViewController:[navigationController.viewControllers lastObject]];
+ }
+ if ([viewController isKindOfClass:[UITabBarController class]]) {
+ UITabBarController *tabController = (UITabBarController *)viewController;
+ return [self topViewControllerFromViewController:tabController.selectedViewController];
+ }
+ if (viewController.presentedViewController) {
+ return [self topViewControllerFromViewController:viewController.presentedViewController];
+ }
+ return viewController;
+}
@end
diff --git a/packages/google_sign_in/ios/google_sign_in.podspec b/packages/google_sign_in/ios/google_sign_in.podspec
index fb51173..73533c6 100755
--- a/packages/google_sign_in/ios/google_sign_in.podspec
+++ b/packages/google_sign_in/ios/google_sign_in.podspec
@@ -15,7 +15,7 @@
s.source_files = 'Classes/**/*'
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Flutter'
- s.dependency 'GoogleSignIn', '~> 4.0'
+ s.dependency 'GoogleSignIn', '~> 5.0'
s.static_framework = true
s.platform = :ios, '8.0'
diff --git a/packages/google_sign_in/pubspec.yaml b/packages/google_sign_in/pubspec.yaml
index 73a607b..e239e01 100644
--- a/packages/google_sign_in/pubspec.yaml
+++ b/packages/google_sign_in/pubspec.yaml
@@ -3,7 +3,7 @@
for signing in with a Google account on Android and iOS.
author: Flutter Team <flutter-dev@googlegroups.com>
homepage: https://github.com/flutter/plugins/tree/master/packages/google_sign_in
-version: 4.0.10
+version: 4.0.11
flutter:
plugin: