# GoogleSignIn Framework Reference

# GIDSignIn

    @interface GIDSignIn : NSObject

This class is used to sign in users with their Google account and manage their session.

For reference, please see "Google Sign-In for iOS and macOS" at
<https://developers.google.com/identity/sign-in/ios>
- `


  ### [sharedInstance](https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignIn#/c:objc(cs)GIDSignIn(cpy)sharedInstance)


  ` The shared `GIDSignIn` instance.

  #### Declaration

  Swift

      class var sharedInstance: GIDSignIn { get }

  Objective-C

      @property (class, nonatomic, readonly) GIDSignIn *_Nonnull sharedInstance;

- `


  ### [currentUser](https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignIn#/c:objc(cs)GIDSignIn(py)currentUser)


  ` The `https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDGoogleUser.html` object representing the current user or `nil` if there is no signed-in user.

  #### Declaration

  Swift

      var currentUser: https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDGoogleUser.html? { get }

  Objective-C

      @property (nonatomic, readonly, nullable) https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDGoogleUser.html *currentUser;

- `


  ### [configuration](https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignIn#/c:objc(cs)GIDSignIn(py)configuration)


  ` The active configuration for this instance of `GIDSignIn`.

  #### Declaration

  Swift

      var configuration: https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDConfiguration.html? { get set }

  Objective-C

      @property (nonatomic, nullable) https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDConfiguration.html *configuration;

- `


  ### [-handleURL:](https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignIn#/c:objc(cs)GIDSignIn(im)handleURL:)


  ` This method should be called from your `UIApplicationDelegate`'s `application:openURL:options:`
  method.

  #### Declaration

  Swift

      func handle(_ url: URL) -> Bool

  Objective-C

      - (BOOL)handleURL:(nonnull NSURL *)url;

  #### Parameters

  |---|---|
  | ` url ` | The URL that was passed to the app. |

  #### Return Value

  `YES` if `GIDSignIn` handled this URL.
- `


  ### [-hasPreviousSignIn](https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignIn#/c:objc(cs)GIDSignIn(im)hasPreviousSignIn)


  ` Checks if there is a previous user sign-in saved in keychain.

  #### Declaration

  Swift

      func hasPreviousSignIn() -> Bool

  Objective-C

      - (BOOL)hasPreviousSignIn;

  #### Return Value

  `YES` if there is a previous user sign-in saved in keychain.
- `


  ### [-restorePreviousSignInWithCompletion:](https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignIn#/c:objc(cs)GIDSignIn(im)restorePreviousSignInWithCompletion:)


  ` Attempts to restore a previous user sign-in without interaction.

  #### Declaration

  Swift

      func restorePreviousSignIn() async throws -> https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDGoogleUser.html

  Objective-C

      - (void)restorePreviousSignInWithCompletion:
          (nullable void (^)(https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDGoogleUser.html *_Nullable, NSError *_Nullable))completion;

  #### Parameters

  |---|---|
  | ` completion ` | The block that is called on completion. This block will be called asynchronously on the main queue. |

- `


  ### [-signOut](https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignIn#/c:objc(cs)GIDSignIn(im)signOut)


  ` Signs out the `https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignIn.html#/c:objc(cs)GIDSignIn(py)currentUser`, removing it from the keychain.

  #### Declaration

  Swift

      func signOut()

  Objective-C

      - (void)signOut;

- `


  ### [-disconnectWithCompletion:](https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignIn#/c:objc(cs)GIDSignIn(im)disconnectWithCompletion:)


  ` Disconnects the `https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignIn.html#/c:objc(cs)GIDSignIn(py)currentUser` by signing them out and revoking all OAuth2 scope grants made to the app.

  #### Declaration

  Swift

      func disconnect() async throws

  Objective-C

      - (void)disconnectWithCompletion:
          (nullable void (^)(NSError *_Nullable))completion;

  #### Parameters

  |---|---|
  | ` completion ` | The optional block that is called on completion. This block will be called asynchronously on the main queue. |

- `


  ### [-signInWithPresentingViewController:completion:](https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignIn#/c:objc(cs)GIDSignIn(im)signInWithPresentingViewController:completion:)


  ` Starts an interactive sign-in flow on iOS.

  The completion will be called at the end of this process. Any saved sign-in state will be
  replaced by the result of this flow. Note that this method should not be called when the app is
  starting up, (e.g in `application:didFinishLaunchingWithOptions:`); instead use the
  `restorePreviousSignInWithCompletion:` method to restore a previous sign-in.

  #### Declaration

  Swift

      func signIn(withPresenting presentingViewController: UIViewController) async throws -> https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignInResult.html

  Objective-C

      - (void)signInWithPresentingViewController:
                  (nonnull UIViewController *)presentingViewController
                                      completion:(nullable void (^)(
                                                     https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignInResult.html *_Nullable,
                                                     NSError *_Nullable))completion;

  #### Parameters

  |---|---|
  | ` presentingViewController ` | The view controller used to present `SFSafariViewContoller` on iOS 9 and 10 and to supply `presentationContextProvider` for `ASWebAuthenticationSession` on iOS 13+. |
  | ` completion ` | The optional block that is called on completion. This block will be called asynchronously on the main queue. |

- `


  ### [-signInWithPresentingViewController:hint:completion:](https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignIn#/c:objc(cs)GIDSignIn(im)signInWithPresentingViewController:hint:completion:)


  ` Starts an interactive sign-in flow on iOS using the provided hint.

  The completion will be called at the end of this process. Any saved sign-in state will be
  replaced by the result of this flow. Note that this method should not be called when the app is
  starting up, (e.g in `application:didFinishLaunchingWithOptions:`); instead use the
  `restorePreviousSignInWithCompletion:` method to restore a previous sign-in.

  #### Declaration

  Swift

      func signIn(withPresenting presentingViewController: UIViewController, hint: String?) async throws -> https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignInResult.html

  Objective-C

      - (void)signInWithPresentingViewController:
                  (nonnull UIViewController *)presentingViewController
                                            hint:(nullable NSString *)hint
                                      completion:(nullable void (^)(
                                                     https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignInResult.html *_Nullable,
                                                     NSError *_Nullable))completion;

  #### Parameters

  |---|---|
  | ` presentingViewController ` | The view controller used to present `SFSafariViewContoller` on iOS 9 and 10 and to supply `presentationContextProvider` for `ASWebAuthenticationSession` on iOS 13+. |
  | ` hint ` | An optional hint for the authorization server, for example the user's ID or email address, to be prefilled if possible. |
  | ` completion ` | The optional block that is called on completion. This block will be called asynchronously on the main queue. |

- `


  ### [-signInWithPresentingViewController:hint:additionalScopes:completion:](https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignIn#/c:objc(cs)GIDSignIn(im)signInWithPresentingViewController:hint:additionalScopes:completion:)


  ` Starts an interactive sign-in flow on iOS using the provided hint and additional scopes.

  The completion will be called at the end of this process. Any saved sign-in state will be
  replaced by the result of this flow. Note that this method should not be called when the app is
  starting up, (e.g in `application:didFinishLaunchingWithOptions:`); instead use the
  `restorePreviousSignInWithCompletion:` method to restore a previous sign-in.

  #### Declaration

  Swift

      func signIn(withPresenting presentingViewController: UIViewController, hint: String?, additionalScopes: [String]?) async throws -> https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignInResult.html

  Objective-C

      - (void)signInWithPresentingViewController:
                  (nonnull UIViewController *)presentingViewController
                                            hint:(nullable NSString *)hint
                                additionalScopes:
                                    (nullable NSArray<NSString *> *)additionalScopes
                                      completion:(nullable void (^)(
                                                     https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignInResult.html *_Nullable,
                                                     NSError *_Nullable))completion;

  #### Parameters

  |---|---|
  | ` presentingViewController ` | The view controller used to present `SFSafariViewContoller` on iOS 9 and 10. |
  | ` hint ` | An optional hint for the authorization server, for example the user's ID or email address, to be prefilled if possible. |
  | ` additionalScopes ` | An optional array of scopes to request in addition to the basic profile scopes. |
  | ` completion ` | The optional block that is called on completion. This block will be called asynchronously on the main queue. |

- `


  ### [-signInWithPresentingWindow:completion:](https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignIn#/c:objc(cs)GIDSignIn(im)signInWithPresentingWindow:completion:)


  ` Starts an interactive sign-in flow on macOS.

  The completion will be called at the end of this process. Any saved sign-in state will be
  replaced by the result of this flow. Note that this method should not be called when the app is
  starting up, (e.g in `application:didFinishLaunchingWithOptions:`); instead use the
  `restorePreviousSignInWithCompletion:` method to restore a previous sign-in.

  #### Declaration

  Swift

      func signIn(withPresentingWindow presentingWindow: Any!) async throws -> https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignInResult.html

  Objective-C

      - (void)signInWithPresentingWindow:(id)presentingWindow
                              completion:
                                  (nullable void (^)(https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignInResult.html *_Nullable,
                                                     NSError *_Nullable))completion;

  #### Parameters

  |---|---|
  | ` presentingWindow ` | The window used to supply `presentationContextProvider` for `ASWebAuthenticationSession`. |
  | ` completion ` | The optional block that is called on completion. This block will be called asynchronously on the main queue. |

- `


  ### [-signInWithPresentingWindow:hint:completion:](https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignIn#/c:objc(cs)GIDSignIn(im)signInWithPresentingWindow:hint:completion:)


  ` Starts an interactive sign-in flow on macOS using the provided hint.

  The completion will be called at the end of this process. Any saved sign-in state will be
  replaced by the result of this flow. Note that this method should not be called when the app is
  starting up, (e.g in `application:didFinishLaunchingWithOptions:`); instead use the
  `restorePreviousSignInWithCompletion:` method to restore a previous sign-in.

  #### Declaration

  Swift

      func signIn(withPresentingWindow presentingWindow: Any!, hint: String?) async throws -> https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignInResult.html

  Objective-C

      - (void)signInWithPresentingWindow:(id)presentingWindow
                                    hint:(nullable NSString *)hint
                              completion:
                                  (nullable void (^)(https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignInResult.html *_Nullable,
                                                     NSError *_Nullable))completion;

  #### Parameters

  |---|---|
  | ` presentingWindow ` | The window used to supply `presentationContextProvider` for `ASWebAuthenticationSession`. |
  | ` hint ` | An optional hint for the authorization server, for example the user's ID or email address, to be prefilled if possible. |
  | ` completion ` | The optional block that is called on completion. This block will be called asynchronously on the main queue. |

- `


  ### [-signInWithPresentingWindow:hint:additionalScopes:completion:](https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignIn#/c:objc(cs)GIDSignIn(im)signInWithPresentingWindow:hint:additionalScopes:completion:)


  ` Starts an interactive sign-in flow on macOS using the provided hint.

  The completion will be called at the end of this process. Any saved sign-in state will be
  replaced by the result of this flow. Note that this method should not be called when the app is
  starting up, (e.g in `application:didFinishLaunchingWithOptions:`); instead use the
  `restorePreviousSignInWithCompletion:` method to restore a previous sign-in.

  #### Declaration

  Swift

      func signIn(withPresentingWindow presentingWindow: Any!, hint: String?, additionalScopes: [String]?) async throws -> https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignInResult.html

  Objective-C

      - (void)signInWithPresentingWindow:(id)presentingWindow
                                    hint:(nullable NSString *)hint
                        additionalScopes:
                            (nullable NSArray<NSString *> *)additionalScopes
                              completion:
                                  (nullable void (^)(https://developers.google.com/identity/sign-in/ios/reference/Classes/GIDSignInResult.html *_Nullable,
                                                     NSError *_Nullable))completion;

  #### Parameters

  |---|---|
  | ` presentingWindow ` | The window used to supply `presentationContextProvider` for `ASWebAuthenticationSession`. |
  | ` hint ` | An optional hint for the authorization server, for example the user's ID or email address, to be prefilled if possible. |
  | ` additionalScopes ` | An optional array of scopes to request in addition to the basic profile scopes. |
  | ` completion ` | The optional block that is called on completion. This block will be called asynchronously on the main queue. |