[go: nahoru, domu]

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

[google_sign_in] Fix deprecated API usage issue by upgrading CocoaPod to 5.0 #2127

Merged
merged 10 commits into from
Oct 29, 2019
Prev Previous commit
Next Next commit
Update to 5.0 compatibility
  • Loading branch information
collinjackson committed Sep 30, 2019
commit 9b7eac550e55751a7da62f471bf3da00deff9614
17 changes: 9 additions & 8 deletions packages/google_sign_in/ios/Classes/GoogleSignInPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
details:error.localizedDescription];
}

@interface FLTGoogleSignInPlugin () <GIDSignInDelegate, GIDSignInUIDelegate>
@interface FLTGoogleSignInPlugin () <GIDSignInDelegate>
@end

@implementation FLTGoogleSignInPlugin {
Expand All @@ -49,8 +49,7 @@ - (instancetype)init {
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.
signal(SIGPIPE, SIG_IGN);
Expand Down Expand Up @@ -84,11 +83,15 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
}
} 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"]) {
// TODO(jackson): It might be more appropriate to use controller of the FlutterView
UIViewController *controller = [UIApplication sharedApplication].keyWindow.rootViewController;
collinjackson marked this conversation as resolved.
Show resolved Hide resolved
[GIDSignIn sharedInstance].presentingViewController = controller;

if ([self setAccountRequest:result]) {
@try {
[[GIDSignIn sharedInstance] signIn];
Expand Down Expand Up @@ -136,9 +139,7 @@ - (BOOL)setAccountRequest:(FlutterResult)request {
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options {
NSString *sourceApplication = options[UIApplicationOpenURLOptionsSourceApplicationKey];
id annotation = options[UIApplicationOpenURLOptionsAnnotationKey];
collinjackson marked this conversation as resolved.
Show resolved Hide resolved
return [[GIDSignIn sharedInstance] handleURL:url
sourceApplication:sourceApplication
annotation:annotation];
return [[GIDSignIn sharedInstance] handleURL:url];
}

#pragma mark - <GIDSignInUIDelegate> protocol
Expand Down