Răsfoiți Sursa

Fix Demo app and improve style

pinlu 3 ani în urmă
părinte
comite
c5a6797ea0

+ 2 - 2
GoogleSignIn/Sources/GIDSignIn_Private.h

@@ -83,8 +83,8 @@ typedef void (^GIDUserAuthCompletion)(GIDUserAuth *_Nullable userAuth, NSError *
 // @param completion The block that is called on completion.  This block will be called asynchronously
 //     on the main queue.
 - (void)addScopes:(NSArray<NSString *> *)scopes
- presentingWindow:(NSWindow *)presentingWindow
-       completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
+    presentingWindow:(NSWindow *)presentingWindow
+          completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
                                      NSError *_Nullable error))completion;
 
 #endif

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

@@ -282,8 +282,8 @@ static NSString *const kCredentialsButtonAccessibilityIdentifier = @"Credentials
 - (IBAction)addScopes:(id)sender {
   GIDGoogleUser *currentUser = GIDSignIn.sharedInstance.currentUser;
   [currentUser addScopes:@[ @"https://www.googleapis.com/auth/user.birthday.read" ]
-      presentingViewController:self
-                    completion:^(GIDUserAuth *_Nullable userAuth,
+    presentingViewController:self
+                  completion:^(GIDUserAuth *_Nullable userAuth,
                                  NSError *_Nullable error) {
     if (error) {
       self->_signInAuthStatus.text = [NSString stringWithFormat:@"Status: Failed to add scopes: %@",

+ 6 - 5
Samples/Swift/DaysUntilBirthday/Shared/Services/GoogleSignInAuthenticator.swift

@@ -83,14 +83,15 @@ final class GoogleSignInAuthenticator: ObservableObject {
   /// - note: Successful requests will update the `authViewModel.state` with a new current user that
   /// has the granted scope.
   func addBirthdayReadScope(completion: @escaping () -> Void) {
+    let currentUser = GIDSignIn.sharedInstance.currentUser
+    
     #if os(iOS)
     guard let rootViewController = UIApplication.shared.windows.first?.rootViewController else {
       fatalError("No root view controller!")
     }
 
-    GIDSignIn.sharedInstance.currentUser?.addScopes(
-      [BirthdayLoader.birthdayReadScope], presenting: rootViewController)
-    { userAuth, error in
+    currentUser?.addScopes([BirthdayLoader.birthdayReadScope],
+                          presenting: rootViewController) { userAuth, error in
       if let error = error {
         print("Found error while adding birthday read scope: \(error).")
         return
@@ -106,8 +107,8 @@ final class GoogleSignInAuthenticator: ObservableObject {
       fatalError("No presenting window!")
     }
 
-    GIDSignIn.sharedInstance.addScopes([BirthdayLoader.birthdayReadScope],
-                                       presenting: presentingWindow) { userAuth, error in
+    currentUser?.addScopes([BirthdayLoader.birthdayReadScope],
+                          presenting: presentingWindow) { userAuth, error in
       if let error = error {
         print("Found error while adding birthday read scope: \(error).")
         return