|
|
@@ -25,7 +25,7 @@
|
|
|
|
|
|
@class GIDConfiguration;
|
|
|
@class GIDGoogleUser;
|
|
|
-@class GIDUserAuth;
|
|
|
+@class GIDSignInResult;
|
|
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
@@ -51,13 +51,13 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) {
|
|
|
kGIDSignInErrorCodeMismatchWithCurrentUser = -9,
|
|
|
};
|
|
|
|
|
|
-/// This class signs the user in with Google.
|
|
|
+/// 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" at
|
|
|
+/// For reference, please see "Google Sign-In for iOS and macOS" at
|
|
|
/// https://developers.google.com/identity/sign-in/ios
|
|
|
@interface GIDSignIn : NSObject
|
|
|
|
|
|
-/// A shared `GIDSignIn` instance.
|
|
|
+/// The shared `GIDSignIn` instance.
|
|
|
@property(class, nonatomic, readonly) GIDSignIn *sharedInstance;
|
|
|
|
|
|
/// The `GIDGoogleUser` object representing the current user or `nil` if there is no signed-in user.
|
|
|
@@ -81,29 +81,29 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) {
|
|
|
/// @return `YES` if `GIDSignIn` handled this URL.
|
|
|
- (BOOL)handleURL:(NSURL *)url;
|
|
|
|
|
|
-/// Checks if there is a previously authenticated user saved in keychain.
|
|
|
+/// Checks if there is a previous user sign-in saved in keychain.
|
|
|
///
|
|
|
-/// @return `YES` if there is a previously authenticated user saved in keychain.
|
|
|
+/// @return `YES` if there is a previous user sign-in saved in keychain.
|
|
|
- (BOOL)hasPreviousSignIn;
|
|
|
|
|
|
-/// Attempts to restore a previously authenticated user without interaction.
|
|
|
+/// Attempts to restore a previous user sign-in without interaction.
|
|
|
///
|
|
|
/// @param completion The block that is called on completion. This block will be called asynchronously
|
|
|
/// on the main queue.
|
|
|
- (void)restorePreviousSignInWithCompletion:(nullable void (^)(GIDGoogleUser *_Nullable user,
|
|
|
NSError *_Nullable error))completion;
|
|
|
|
|
|
-/// Marks current user as being in the signed out state.
|
|
|
+/// Signs out the `currentUser`, removing it from the keychain.
|
|
|
- (void)signOut;
|
|
|
|
|
|
-/// Disconnects the current user from the app and revokes previous authentication. If the operation
|
|
|
-/// succeeds, the OAuth 2.0 token is also removed from keychain.
|
|
|
+/// Disconnects the `currentUser` by signing them out and revoking all OAuth2 scope grants made to the app.
|
|
|
///
|
|
|
/// @param completion The optional block that is called on completion.
|
|
|
/// This block will be called asynchronously on the main queue.
|
|
|
- (void)disconnectWithCompletion:(nullable void (^)(NSError *_Nullable error))completion;
|
|
|
|
|
|
#if TARGET_OS_IOS || TARGET_OS_MACCATALYST
|
|
|
+
|
|
|
/// 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
|
|
|
@@ -114,11 +114,12 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) {
|
|
|
/// @param presentingViewController The view controller used to present `SFSafariViewContoller` on
|
|
|
/// iOS 9 and 10 and to supply `presentationContextProvider` for `ASWebAuthenticationSession` on
|
|
|
/// iOS 13+.
|
|
|
-/// @param completion The `GIDSignInCompletion` block that is called on completion. This block will
|
|
|
+/// @param completion The optional block that is called on completion. This block will
|
|
|
/// be called asynchronously on the main queue.
|
|
|
- (void)signInWithPresentingViewController:(UIViewController *)presentingViewController
|
|
|
- completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
|
|
|
- NSError *_Nullable error))completion
|
|
|
+ completion:
|
|
|
+ (nullable void (^)(GIDSignInResult *_Nullable signInResult,
|
|
|
+ NSError *_Nullable error))completion
|
|
|
NS_EXTENSION_UNAVAILABLE("The sign-in flow is not supported in App Extensions.");
|
|
|
|
|
|
/// Starts an interactive sign-in flow on iOS using the provided hint.
|
|
|
@@ -133,12 +134,13 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) {
|
|
|
/// iOS 13+.
|
|
|
/// @param hint An optional hint for the authorization server, for example the user's ID or email
|
|
|
/// address, to be prefilled if possible.
|
|
|
-/// @param completion The `GIDSignInCompletion` block that is called on completion. This block will
|
|
|
+/// @param completion The optional block that is called on completion. This block will
|
|
|
/// be called asynchronously on the main queue.
|
|
|
- (void)signInWithPresentingViewController:(UIViewController *)presentingViewController
|
|
|
hint:(nullable NSString *)hint
|
|
|
- completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
|
|
|
- NSError *_Nullable error))completion
|
|
|
+ completion:
|
|
|
+ (nullable void (^)(GIDSignInResult *_Nullable signInResult,
|
|
|
+ NSError *_Nullable error))completion
|
|
|
NS_EXTENSION_UNAVAILABLE("The sign-in flow is not supported in App Extensions.");
|
|
|
|
|
|
/// Starts an interactive sign-in flow on iOS using the provided hint and additional scopes.
|
|
|
@@ -153,17 +155,18 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) {
|
|
|
/// @param hint An optional hint for the authorization server, for example the user's ID or email
|
|
|
/// address, to be prefilled if possible.
|
|
|
/// @param additionalScopes An optional array of scopes to request in addition to the basic profile scopes.
|
|
|
-/// @param completion The `GIDSignInCompletion` block that is called on completion. This block will
|
|
|
+/// @param completion The optional block that is called on completion. This block will
|
|
|
/// be called asynchronously on the main queue.
|
|
|
-
|
|
|
- (void)signInWithPresentingViewController:(UIViewController *)presentingViewController
|
|
|
hint:(nullable NSString *)hint
|
|
|
additionalScopes:(nullable NSArray<NSString *> *)additionalScopes
|
|
|
- completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
|
|
|
- NSError *_Nullable error))completion
|
|
|
+ completion:
|
|
|
+ (nullable void (^)(GIDSignInResult *_Nullable signInResult,
|
|
|
+ NSError *_Nullable error))completion
|
|
|
NS_EXTENSION_UNAVAILABLE("The sign-in flow is not supported in App Extensions.");
|
|
|
|
|
|
#elif TARGET_OS_OSX
|
|
|
+
|
|
|
/// 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
|
|
|
@@ -172,10 +175,10 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) {
|
|
|
/// `restorePreviousSignInWithCompletion:` method to restore a previous sign-in.
|
|
|
///
|
|
|
/// @param presentingWindow The window used to supply `presentationContextProvider` for `ASWebAuthenticationSession`.
|
|
|
-/// @param completion The `GIDSignInCompletion` block that is called on completion. This block will
|
|
|
+/// @param completion The optional block that is called on completion. This block will
|
|
|
/// be called asynchronously on the main queue.
|
|
|
- (void)signInWithPresentingWindow:(NSWindow *)presentingWindow
|
|
|
- completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
|
|
|
+ completion:(nullable void (^)(GIDSignInResult *_Nullable signInResult,
|
|
|
NSError *_Nullable error))completion;
|
|
|
|
|
|
/// Starts an interactive sign-in flow on macOS using the provided hint.
|
|
|
@@ -188,11 +191,11 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) {
|
|
|
/// @param presentingWindow The window used to supply `presentationContextProvider` for `ASWebAuthenticationSession`.
|
|
|
/// @param hint An optional hint for the authorization server, for example the user's ID or email
|
|
|
/// address, to be prefilled if possible.
|
|
|
-/// @param completion The `GIDSignInCompletion` block that is called on completion. This block will
|
|
|
+/// @param completion The optional block that is called on completion. This block will
|
|
|
/// be called asynchronously on the main queue.
|
|
|
- (void)signInWithPresentingWindow:(NSWindow *)presentingWindow
|
|
|
hint:(nullable NSString *)hint
|
|
|
- completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
|
|
|
+ completion:(nullable void (^)(GIDSignInResult *_Nullable signInResult,
|
|
|
NSError *_Nullable error))completion;
|
|
|
|
|
|
/// Starts an interactive sign-in flow on macOS using the provided hint.
|
|
|
@@ -206,12 +209,12 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) {
|
|
|
/// @param hint An optional hint for the authorization server, for example the user's ID or email
|
|
|
/// address, to be prefilled if possible.
|
|
|
/// @param additionalScopes An optional array of scopes to request in addition to the basic profile scopes.
|
|
|
-/// @param completion The `GIDSignInCompletion` block that is called on completion. This block will
|
|
|
+/// @param completion The optional block that is called on completion. This block will
|
|
|
/// be called asynchronously on the main queue.
|
|
|
- (void)signInWithPresentingWindow:(NSWindow *)presentingWindow
|
|
|
hint:(nullable NSString *)hint
|
|
|
additionalScopes:(nullable NSArray<NSString *> *)additionalScopes
|
|
|
- completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
|
|
|
+ completion:(nullable void (^)(GIDSignInResult *_Nullable signInResult,
|
|
|
NSError *_Nullable error))completion;
|
|
|
|
|
|
#endif
|