Browse Source

Change GIDSignInCallback in sample apps.

pinlu 3 years ago
parent
commit
5d23b41248

+ 0 - 2
GoogleSignIn/Sources/GIDSignInInternalOptions.h

@@ -22,8 +22,6 @@
 #import <AppKit/AppKit.h>
 #endif
 
-#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h"
-
 @class GIDConfiguration;
 @class GIDUserAuth;
 

+ 1 - 1
Samples/ObjC/SignInSample/Source/AppDelegate.m

@@ -30,7 +30,7 @@
   // succeeds, we'll have a currentUser and the view will be able to draw its UI for the signed-in
   // state.  If the restore fails, currentUser will be nil and we'll draw the signed-out state
   // prompting the user to sign in.
-  [GIDSignIn.sharedInstance restorePreviousSignInWithCallback:^(GIDGoogleUser * _Nullable user,
+  [GIDSignIn.sharedInstance restorePreviousSignInWithCallback:^(GIDUserAuth * _Nullable userAuth,
                                                                 NSError * _Nullable error) {
     self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
     SignInViewController *masterViewController =

+ 2 - 2
Samples/ObjC/SignInSample/Source/SignInViewController.m

@@ -259,7 +259,7 @@ static NSString * const kClientID =
 - (IBAction)signIn:(id)sender {
   [GIDSignIn.sharedInstance signInWithConfiguration:_configuration
                            presentingViewController:self
-                                           callback:^(GIDGoogleUser * _Nullable user,
+                                           callback:^(GIDUserAuth * _Nullable userAuth,
                                                       NSError * _Nullable error) {
     if (error) {
       self->_signInAuthStatus.text =
@@ -293,7 +293,7 @@ static NSString * const kClientID =
 - (IBAction)addScopes:(id)sender {
   [GIDSignIn.sharedInstance addScopes:@[ @"https://www.googleapis.com/auth/user.birthday.read" ]
              presentingViewController:self
-                             callback:^(GIDGoogleUser * _Nullable user,
+                             callback:^(GIDUserAuth * _Nullable userAuth,
                                         NSError * _Nullable error) {
     if (error) {
       self->_signInAuthStatus.text = [NSString stringWithFormat:@"Status: Failed to add scopes: %@",

+ 3 - 3
Samples/Swift/DaysUntilBirthday/Shared/DaysUntilBirthday.swift

@@ -26,9 +26,9 @@ struct DaysUntilBirthday: App {
       ContentView()
         .environmentObject(authViewModel)
         .onAppear {
-          GIDSignIn.sharedInstance.restorePreviousSignIn { user, error in
-            if let user = user {
-              self.authViewModel.state = .signedIn(user)
+          GIDSignIn.sharedInstance.restorePreviousSignIn { userAuth, error in
+            if let userAuth = userAuth {
+              self.authViewModel.state = .signedIn(userAuth.user)
             } else if let error = error {
               self.authViewModel.state = .signedOut
               print("There was an error restoring the previous sign-in: \(error)")

+ 12 - 12
Samples/Swift/DaysUntilBirthday/Shared/Services/GoogleSignInAuthenticator.swift

@@ -48,12 +48,12 @@ final class GoogleSignInAuthenticator: ObservableObject {
     }
 
     GIDSignIn.sharedInstance.signIn(with: configuration,
-                                    presenting: rootViewController) { user, error in
-      guard let user = user else {
+                                    presenting: rootViewController) { userAuth, error in
+      guard let userAuth = userAuth else {
         print("Error! \(String(describing: error))")
         return
       }
-      self.authViewModel.state = .signedIn(user)
+      self.authViewModel.state = .signedIn(userAuth.user)
     }
 
 #elseif os(macOS)
@@ -63,12 +63,12 @@ final class GoogleSignInAuthenticator: ObservableObject {
     }
 
     GIDSignIn.sharedInstance.signIn(with: configuration,
-                                    presenting: presentingWindow) { user, error in
-      guard let user = user else {
+                                    presenting: presentingWindow) { userAuth, error in
+      guard let userAuth = userAuth else {
         print("Error! \(String(describing: error))")
         return
       }
-      self.authViewModel.state = .signedIn(user)
+      self.authViewModel.state = .signedIn(userAuth.user)
     }
 #endif
   }
@@ -102,14 +102,14 @@ final class GoogleSignInAuthenticator: ObservableObject {
     }
 
     GIDSignIn.sharedInstance.addScopes([BirthdayLoader.birthdayReadScope],
-                                       presenting: rootViewController) { user, error in
+                                       presenting: rootViewController) { userAuth, error in
       if let error = error {
         print("Found error while adding birthday read scope: \(error).")
         return
       }
 
-      guard let currentUser = user else { return }
-      self.authViewModel.state = .signedIn(currentUser)
+      guard let userAuth = userAuth else { return }
+      self.authViewModel.state = .signedIn(userAuth.user)
       completion()
     }
 
@@ -119,14 +119,14 @@ final class GoogleSignInAuthenticator: ObservableObject {
     }
 
     GIDSignIn.sharedInstance.addScopes([BirthdayLoader.birthdayReadScope],
-                                       presenting: presentingWindow) { user, error in
+                                       presenting: presentingWindow) { userAuth, error in
       if let error = error {
         print("Found error while adding birthday read scope: \(error).")
         return
       }
 
-      guard let currentUser = user else { return }
-      self.authViewModel.state = .signedIn(currentUser)
+      guard let userAuth = userAuth else { return }
+      self.authViewModel.state = .signedIn(userAuth.user)
       completion()
     }