FIRPhoneAuthProvider.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. /** @typedef FIRVerificationResultCallback
  26. @brief The type of block invoked when a request to send a verification code has finished.
  27. @param verificationID On success, the verification ID provided, nil otherwise.
  28. @param error On error, the error that occured, nil otherwise.
  29. */
  30. typedef void (^FIRVerificationResultCallback)(NSString *_Nullable verificationID,
  31. NSError *_Nullable error)
  32. NS_SWIFT_NAME(VerificationResultCallback);
  33. /** @class FIRPhoneAuthProvider
  34. @brief A concrete implementation of `FIRAuthProvider` for phone auth providers.
  35. */
  36. NS_SWIFT_NAME(PhoneAuthProvider)
  37. @interface FIRPhoneAuthProvider : NSObject
  38. /** @fn provider
  39. @brief Returns an instance of `FIRPhoneAuthProvider` for the default `FIRAuth` object.
  40. */
  41. + (instancetype)provider NS_SWIFT_NAME(provider());
  42. /** @fn providerWithAuth:
  43. @brief Returns an instance of `FIRPhoneAuthProvider` for the provided `FIRAuth` object.
  44. @param auth The auth object to associate with the phone auth provider instance.
  45. */
  46. + (instancetype)providerWithAuth:(FIRAuth *)auth NS_SWIFT_NAME(provider(auth:));
  47. /** @fn verifyPhoneNumber:completion:
  48. @brief Please use `verifyPhoneNumber:UIDelegate:completion:` instead.
  49. @param phoneNumber The phone number to be verified.
  50. @param completion The callback to be invoked when the verification flow is finished.
  51. @remarks Possible error codes:
  52. + `FIRAuthErrorCodeAppNotVerified` - Indicates that Firebase could not retrieve the
  53. silent push notification and therefore could not verify your app.
  54. + `FIRAuthErrorCodeInvalidAppCredential` - Indicates that The APNs device token provided
  55. is either incorrect or does not match the private certificate uploaded to the Firebase
  56. Console.
  57. + `FIRAuthErrorCodeQuotaExceeded` - Indicates that the phone verification quota for this
  58. project has been exceeded.
  59. + `FIRAuthErrorCodeInvalidPhoneNumber` - Indicates that the phone number provided is
  60. invalid.
  61. + `FIRAuthErrorCodeMissingPhoneNumber` - Indicates that a phone number was not provided.
  62. + `FIRAuthErrorCodeMissingAppToken` - Indicates that the APNs device token could not be
  63. obtained. The app may not have set up remote notification correctly, or may fail to
  64. forward the APNs device token to FIRAuth if app delegate swizzling is disabled.
  65. */
  66. - (void)verifyPhoneNumber:(NSString *)phoneNumber
  67. completion:(nullable FIRVerificationResultCallback)completion
  68. __attribute__((deprecated));
  69. /** @fn verifyPhoneNumber:UIDelegate:completion:
  70. @brief Starts the phone number authentication flow by sending a verifcation code to the
  71. specified phone number.
  72. @param phoneNumber The phone number to be verified.
  73. @param UIDelegate An object used to present the SFSafariViewController. The object is retained
  74. by this method until the completion block is executed.
  75. @param completion The callback to be invoked when the verification flow is finished.
  76. @remarks Possible error codes:
  77. + `FIRAuthErrorCodeCaptchaCheckFailed` - Indicates that the reCAPTCHA token obtained by
  78. the Firebase Auth is invalid or has expired.
  79. + `FIRAuthErrorCodeQuotaExceeded` - Indicates that the phone verification quota for this
  80. project has been exceeded.
  81. + `FIRAuthErrorCodeInvalidPhoneNumber` - Indicates that the phone number provided is
  82. invalid.
  83. + `FIRAuthErrorCodeMissingPhoneNumber` - Indicates that a phone number was not provided.
  84. */
  85. - (void)verifyPhoneNumber:(NSString *)phoneNumber
  86. UIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
  87. completion:(nullable FIRVerificationResultCallback)completion;
  88. /** @fn credentialWithVerificationID:verificationCode:
  89. @brief Creates an `FIRAuthCredential` for the phone number provider identified by the
  90. verification ID and verification code.
  91. @param verificationID The verification ID obtained from invoking
  92. verifyPhoneNumber:completion:
  93. @param verificationCode The verification code obtained from the user.
  94. @return The corresponding phone auth credential for the verification ID and verification code
  95. provided.
  96. */
  97. - (FIRPhoneAuthCredential *)credentialWithVerificationID:(NSString *)verificationID
  98. verificationCode:(NSString *)verificationCode;
  99. /** @fn init
  100. @brief Please use the `provider` or `providerWithAuth:` methods to obtain an instance of
  101. `FIRPhoneAuthProvider`.
  102. */
  103. - (instancetype)init NS_UNAVAILABLE;
  104. @end
  105. NS_ASSUME_NONNULL_END