Skip to content

Commit 85781d0

Browse files
authored
Bump Google Sign-In SDK version for Auth sample app. (#10024)
1 parent 8717f71 commit 85781d0

File tree

2 files changed

+7
-71
lines changed

2 files changed

+7
-71
lines changed

FirebaseAuth/Tests/Sample/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ target 'AuthSample' do
1616
pod 'FirebaseAuth', :path => '../../../', :testspecs => ['unit']
1717
pod 'FirebaseInstallations', :path => '../../..'
1818
pod 'FBSDKLoginKit'
19-
pod 'GoogleSignIn', '~> 5'
19+
pod 'GoogleSignIn', '~> 6'
2020
pod 'GTMSessionFetcher/Core'
2121

2222
target 'Auth_ApiTests' do

FirebaseAuth/Tests/Sample/Sample/GoogleAuthProvider.m

Lines changed: 6 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -22,75 +22,18 @@
2222
#import <FirebaseCore/FIRApp.h>
2323
#import <FirebaseCore/FIROptions.h>
2424
#import <FirebaseAuth/FIRGoogleAuthProvider.h>
25-
#import "ApplicationDelegate.h"
26-
27-
/** @typedef GoogleSignInCallback
28-
@brief The type of block invoked when a @c GIDGoogleUser object is ready or an error has
29-
occurred.
30-
@param user The Google user if any.
31-
@param error The error which occurred, if any.
32-
*/
33-
typedef void (^GoogleSignInCallback)(GIDGoogleUser *user, NSError *error);
34-
35-
/** @class GoogleAuthDelegate
36-
@brief The designated delegate class for Google Sign-In.
37-
*/
38-
@interface GoogleAuthDelegate : NSObject <GIDSignInDelegate, OpenURLDelegate>
39-
40-
/** @fn initWithPresentingViewController:callback:
41-
@brief Initializes the new instance with the callback.
42-
@param presentingViewController The view controller to present the UI.
43-
@param callback A block which is invoked when the sign-in flow finishes. Invoked asynchronously
44-
on an unspecified thread in the future.
45-
*/
46-
- (instancetype)initWithPresentingViewController:(UIViewController *)presentingViewController
47-
callback:(nullable GoogleSignInCallback)callback;
48-
49-
@end
50-
51-
@implementation GoogleAuthDelegate {
52-
UIViewController *_presentingViewController;
53-
GoogleSignInCallback _callback;
54-
}
55-
56-
- (instancetype)initWithPresentingViewController:(UIViewController *)presentingViewController
57-
callback:(nullable GoogleSignInCallback)callback {
58-
self = [super init];
59-
if (self) {
60-
_presentingViewController = presentingViewController;
61-
_callback = callback;
62-
}
63-
return self;
64-
}
65-
66-
- (void)signIn:(GIDSignIn *)signIn
67-
didSignInForUser:(GIDGoogleUser *)user
68-
withError:(NSError *)error {
69-
GoogleSignInCallback callback = _callback;
70-
_callback = nil;
71-
if (callback) {
72-
callback(user, error);
73-
}
74-
}
75-
76-
- (BOOL)handleOpenURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication {
77-
return [[GIDSignIn sharedInstance] handleURL:url];
78-
}
79-
80-
@end
8125

8226
@implementation GoogleAuthProvider
8327

8428
- (void)getAuthCredentialWithPresentingViewController:(UIViewController *)viewController
8529
callback:(AuthCredentialCallback)callback {
8630
[self signOut];
8731

88-
// The delegate needs to be retained.
89-
__block GoogleAuthDelegate *delegate = [[GoogleAuthDelegate alloc]
90-
initWithPresentingViewController:viewController
91-
callback:^(GIDGoogleUser *user, NSError *error) {
92-
[ApplicationDelegate setOpenURLDelegate:nil];
93-
delegate = nil;
32+
GIDSignIn *signIn = GIDSignIn.sharedInstance;
33+
GIDConfiguration *config = [[GIDConfiguration alloc] initWithClientID:[self googleClientID]];
34+
[signIn signInWithConfiguration:config
35+
presentingViewController:viewController
36+
callback:^(GIDGoogleUser * _Nullable user, NSError * _Nullable error) {
9437
if (error) {
9538
callback(nil, error);
9639
return;
@@ -100,17 +43,10 @@ - (void)getAuthCredentialWithPresentingViewController:(UIViewController *)viewCo
10043
accessToken:auth.accessToken];
10144
callback(credential, error);
10245
}];
103-
GIDSignIn *signIn = [GIDSignIn sharedInstance];
104-
signIn.clientID = [self googleClientID];
105-
signIn.shouldFetchBasicProfile = YES;
106-
signIn.delegate = delegate;
107-
signIn.presentingViewController = viewController;
108-
[ApplicationDelegate setOpenURLDelegate:delegate];
109-
[signIn signIn];
11046
}
11147

11248
- (void)signOut {
113-
[[GIDSignIn sharedInstance] signOut];
49+
[GIDSignIn.sharedInstance signOut];
11450
}
11551

11652
- (NSString *)googleClientID {

0 commit comments

Comments
 (0)