GIDSignInInternalOptions.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * Copyright 2021 Google LLC
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. #if __has_include(<UIKit/UIKit.h>)
  18. #import <UIKit/UIKit.h>
  19. #elif __has_include(<AppKit/AppKit.h>)
  20. #import <AppKit/AppKit.h>
  21. #endif
  22. #import "GoogleSignIn/Sources/GIDSignIn_Private.h"
  23. #if TARGET_OS_IOS
  24. #import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDVerifyAccountDetail.h"
  25. #endif // TARGET_OS_IOS
  26. @class GIDConfiguration;
  27. @class GIDSignInResult;
  28. NS_ASSUME_NONNULL_BEGIN
  29. /// The options used internally for aspects of the sign-in flow.
  30. @interface GIDSignInInternalOptions : NSObject
  31. /// Whether interaction with user is allowed at all.
  32. @property(nonatomic, readonly) BOOL interactive;
  33. /// Whether the sign-in is a continuation of the previous one.
  34. @property(nonatomic, readonly) BOOL continuation;
  35. /// Whether the sign-in is an addScopes flow. NO means it is a sign in flow.
  36. @property(nonatomic, readonly) BOOL addScopesFlow;
  37. #if TARGET_OS_IOS
  38. /// The user account details the Verify with Google flow will verify
  39. @property(nonatomic, copy, nullable, readonly) NSArray<GIDVerifiableAccountDetail *> *accountDetailsToVerify;
  40. #endif // TARGET_OS_IOS
  41. /// The extra parameters used in the sign-in URL.
  42. @property(nonatomic, readonly, nullable) NSDictionary *extraParams;
  43. /// The configuration to use during the flow.
  44. @property(nonatomic, readonly, nullable) GIDConfiguration *configuration;
  45. #if TARGET_OS_IOS || TARGET_OS_MACCATALYST
  46. /// The view controller to use during the flow.
  47. @property(nonatomic, readonly, weak, nullable) UIViewController *presentingViewController;
  48. #elif TARGET_OS_OSX
  49. /// The window to use during the flow.
  50. @property(nonatomic, readonly, weak, nullable) NSWindow *presentingWindow;
  51. #endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
  52. /// The completion block to be called at the completion of the flow.
  53. @property(nonatomic, readonly, nullable) GIDSignInCompletion completion;
  54. #if TARGET_OS_IOS
  55. /// The completion block to be called at the completion of the verify flow.
  56. @property(nonatomic, readonly, nullable) GIDVerifyCompletion verifyCompletion;
  57. #endif // TARGET_OS_IOS
  58. /// The scopes to be used during the flow.
  59. @property(nonatomic, copy, nullable) NSArray<NSString *> *scopes;
  60. /// The login hint to be used during the flow.
  61. @property(nonatomic, copy, nullable) NSString *loginHint;
  62. /// Creates the default options.
  63. #if TARGET_OS_IOS
  64. + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
  65. presentingViewController:(nullable UIViewController *)presentingViewController
  66. loginHint:(nullable NSString *)loginHint
  67. addScopesFlow:(BOOL)addScopesFlow
  68. accountDetailsToVerify:(NSArray<GIDVerifiableAccountDetail *> *)accountDetailsToVerify
  69. verifyCompletion:(nullable GIDVerifyCompletion)completion;
  70. #endif // TARGET_OS_IOS
  71. #if TARGET_OS_IOS || TARGET_OS_MACCATALYST
  72. + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
  73. presentingViewController:(nullable UIViewController *)presentingViewController
  74. loginHint:(nullable NSString *)loginHint
  75. addScopesFlow:(BOOL)addScopesFlow
  76. completion:(nullable GIDSignInCompletion)completion;
  77. + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
  78. presentingViewController:(nullable UIViewController *)presentingViewController
  79. loginHint:(nullable NSString *)loginHint
  80. addScopesFlow:(BOOL)addScopesFlow
  81. scopes:(nullable NSArray *)scopes
  82. completion:(nullable GIDSignInCompletion)completion;
  83. #elif TARGET_OS_OSX
  84. + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
  85. presentingWindow:(nullable NSWindow *)presentingWindow
  86. loginHint:(nullable NSString *)loginHint
  87. addScopesFlow:(BOOL)addScopesFlow
  88. completion:(nullable GIDSignInCompletion)completion;
  89. + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
  90. presentingWindow:(nullable NSWindow *)presentingWindow
  91. loginHint:(nullable NSString *)loginHint
  92. addScopesFlow:(BOOL)addScopesFlow
  93. scopes:(nullable NSArray *)scopes
  94. completion:(nullable GIDSignInCompletion)completion;
  95. #endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
  96. /// Creates the options to sign in silently.
  97. + (instancetype)silentOptionsWithCompletion:(GIDSignInCompletion)completion;
  98. /// Creates options with the same values as the receiver, except for the "extra parameters", and
  99. /// continuation flag, which are replaced by the arguments passed to this method.
  100. - (instancetype)optionsWithExtraParameters:(NSDictionary *)extraParams
  101. forContinuation:(BOOL)continuation;
  102. @end
  103. NS_ASSUME_NONNULL_END