This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[google_sign_in] Fix deprecated API usage issue by upgrading CocoaPod to 5.0 #2127
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
710283b
Fix Deprecated API Usage issue
collinjackson 9b7eac5
Update to 5.0 compatibility
collinjackson 89187b5
reformat
collinjackson 46d23e3
Update to use [registrar messenger]
collinjackson f0bb3ce
Merge remote-tracking branch 'origin/master' into google_sign_in
collinjackson 52ed349
Implement code review feedback
collinjackson 34abc18
Remove dead code
collinjackson 2faa78b
Merge remote-tracking branch 'origin/master' into google_sign_in
collinjackson bb5c3eb
format
collinjackson e3a79a8
Merge remote-tracking branch 'origin/master' into google_sign_in
collinjackson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update to use [registrar messenger]
- Loading branch information
commit 46d23e36f7dad7d98e0791418c73e3ad3d36a49c
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,15 +40,16 @@ + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar { | |
FlutterMethodChannel *channel = | ||
[FlutterMethodChannel methodChannelWithName:@"plugins.flutter.io/google_sign_in" | ||
binaryMessenger:[registrar messenger]]; | ||
FLTGoogleSignInPlugin *instance = [[FLTGoogleSignInPlugin alloc] init]; | ||
FLTGoogleSignInPlugin *instance = [[FLTGoogleSignInPlugin alloc] initWithController:[registrar messenger]]; | ||
[registrar addApplicationDelegate:instance]; | ||
[registrar addMethodCallDelegate:instance channel:channel]; | ||
} | ||
|
||
- (instancetype)init { | ||
- (instancetype)initWithController:(id)controller { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This changes the designated initializer from GoogleSignInPlugin.h can indicate this: #import <Flutter/Flutter.h>
NS_ASSUME_NONNULL_BEGIN
@interface FLTGoogleSignInPlugin : NSObject <FlutterPlugin>
- (instancetype)initWithController:(id)controller NS_DESIGNATED_INITIALIZER;
- (instancetype)init NS_UNAVAILABLE;
@end
NS_ASSUME_NONNULL_END
Also, it looks like this should be a |
||
self = [super init]; | ||
if (self) { | ||
[GIDSignIn sharedInstance].delegate = self; | ||
[GIDSignIn sharedInstance].presentingViewController = controller; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That header says: // The view controller used to present |SFSafariViewContoller| on iOS 9 and 10.
@property(nonatomic, weak) UIViewController *presentingViewController; Does that mean this is only applicable for iOS 9 and 10? |
||
|
||
// 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. | ||
|
@@ -88,10 +89,6 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result | |
} else if ([call.method isEqualToString:@"isSignedIn"]) { | ||
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; | ||
[GIDSignIn sharedInstance].presentingViewController = controller; | ||
|
||
if ([self setAccountRequest:result]) { | ||
@try { | ||
[[GIDSignIn sharedInstance] signIn]; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to be a problem for you. You are ignoring types and forcing a binary messenger to be a view controller? Once you fix that, you'll find that the binary messenger isn't really a view controller anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I do something like this?
Or should the app developer manually pass their
FlutterViewController
to the plugin? I'm not sure what the best approach is here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if grabbing the rootViewController here is going to work for you since the rootViewController might not still be the same rootViewController when GIDSignIn actually wants to present something. Also, I'm not sure what it would do if the rootViewController was a UINavigationController and its topmost view is a FlutterViewController, would it display correctly? You might have to try that out.
You might want to move the setter to the handle method call, is it possible GIDSignIn will want to display something without a method having triggered it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, i don't know if sending the FlutterViewController will work since I don't think there is a mechanism to do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that there probably isn't a mechanism to that.
I'm fine with grabbing the
rootViewController
at the time that the sign-in happens if you think that's a reasonable approach. It seems like the sign-in method is the only time that this gets used.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the approach as described, PTAL