Ingen beskrivning

FIRPhoneAuthProvider.h 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright 2017 Google
  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. @class FIRAuth;
  18. @class FIRPhoneAuthCredential;
  19. @protocol FIRAuthUIDelegate;
  20. NS_ASSUME_NONNULL_BEGIN
  21. /** @var FIRPhoneAuthProviderID
  22. @brief A string constant identifying the phone identity provider.
  23. */
  24. extern NSString *const FIRPhoneAuthProviderID NS_SWIFT_NAME(PhoneAuthProviderID);
  25. /** @var FIRPhoneAuthProviderID
  26. @brief A string constant identifying the phone sign-in method.
  27. */
  28. extern NSString *const _Nonnull FIRPhoneAuthSignInMethod NS_SWIFT_NAME(PhoneAuthSignInMethod);
  29. /** @typedef FIRVerificationResultCallback
  30. @brief The type of block invoked when a request to send a verification code has finished.
  31. @param verificationID On success, the verification ID provided, nil otherwise.
  32. @param error On error, the error that occurred, nil otherwise.
  33. */
  34. typedef void (^FIRVerificationResultCallback)
  35. (NSString *_Nullable verificationID, NSError *_Nullable error)
  36. NS_SWIFT_NAME(VerificationResultCallback);
  37. /** @class FIRPhoneAuthProvider
  38. @brief A concrete implementation of `FIRAuthProvider` for phone auth providers.
  39. */
  40. NS_SWIFT_NAME(PhoneAuthProvider)
  41. @interface FIRPhoneAuthProvider : NSObject
  42. /** @fn provider
  43. @brief Returns an instance of `FIRPhoneAuthProvider` for the default `FIRAuth` object.
  44. */
  45. + (instancetype)provider NS_SWIFT_NAME(provider());
  46. /** @fn providerWithAuth:
  47. @brief Returns an instance of `FIRPhoneAuthProvider` for the provided `FIRAuth` object.
  48. @param auth The auth object to associate with the phone auth provider instance.
  49. */
  50. + (instancetype)providerWithAuth:(FIRAuth *)auth NS_SWIFT_NAME(provider(auth:));
  51. /** @fn verifyPhoneNumber:UIDelegate:completion:
  52. @brief Starts the phone number authentication flow by sending a verification code to the
  53. specified phone number.
  54. @param phoneNumber The phone number to be verified.
  55. @param UIDelegate An object used to present the SFSafariViewController. The object is retained
  56. by this method until the completion block is executed.
  57. @param completion The callback to be invoked when the verification flow is finished.
  58. @remarks Possible error codes:
  59. + `FIRAuthErrorCodeCaptchaCheckFailed` - Indicates that the reCAPTCHA token obtained by
  60. the Firebase Auth is invalid or has expired.
  61. + `FIRAuthErrorCodeQuotaExceeded` - Indicates that the phone verification quota for this
  62. project has been exceeded.
  63. + `FIRAuthErrorCodeInvalidPhoneNumber` - Indicates that the phone number provided is
  64. invalid.
  65. + `FIRAuthErrorCodeMissingPhoneNumber` - Indicates that a phone number was not provided.
  66. */
  67. - (void)verifyPhoneNumber:(NSString *)phoneNumber
  68. UIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
  69. completion:(nullable FIRVerificationResultCallback)completion;
  70. /** @fn credentialWithVerificationID:verificationCode:
  71. @brief Creates an `FIRAuthCredential` for the phone number provider identified by the
  72. verification ID and verification code.
  73. @param verificationID The verification ID obtained from invoking
  74. verifyPhoneNumber:completion:
  75. @param verificationCode The verification code obtained from the user.
  76. @return The corresponding phone auth credential for the verification ID and verification code
  77. provided.
  78. */
  79. - (FIRPhoneAuthCredential *)credentialWithVerificationID:(NSString *)verificationID
  80. verificationCode:(NSString *)verificationCode;
  81. /** @fn init
  82. @brief Please use the `provider` or `providerWithAuth:` methods to obtain an instance of
  83. `FIRPhoneAuthProvider`.
  84. */
  85. - (instancetype)init NS_UNAVAILABLE;
  86. @end
  87. NS_ASSUME_NONNULL_END