الانتقال إلى وحدة التحكم

Firebase.Auth.PhoneAuthProvider

Use phone number text messages to authenticate.

Summary

Allows developers to use the phone number and SMS verification codes to authenticate a user.

The verification flow results in a Credential that can be used to,

  • Sign in to an existing phone number account/sign up with a new phone number
  • Link a phone number to a current user. This provider will be added to the user.
  • Update a phone number on an existing user.
  • Re-authenticate an existing user. This may be needed when a sensitive operation requires the user to be recently logged in.

Possible verification flows: (1) User manually enters verification code.

  • App calls VerifyPhoneNumber.
  • Web verification page is displayed to user where they may need to solve a CAPTCHA. [iOS only].
  • Auth server sends the verification code via SMS to the provided phone number. App receives verification id via CodeSent.
  • User receives SMS and enters verification code in app's GUI.
  • App uses user's verification code to call PhoneAuthProvider.GetCredential.

(2) SMS is automatically retrieved (Android only).

  • App calls VerifyPhoneNumber with timeout_ms > 0.
  • Auth server sends the verification code via SMS to the provided phone number.
  • SMS arrives and is automatically retrieved by the operating system. Credential is automatically created and passed to the app via VerificationCompleted.

(3) Phone number is instantly verified (Android only).

Inheritance

Inherits from: SystemIDisposable

Properties

MaxTimeoutMs
static uint
Maximum value of autoVerifyTimeOutMs in VerifyPhoneNumber.

Public functions

CodeAutoRetrievalTimeOut(string verificationId)
delegate void
Callback used when a timeout occurs.
CodeSent(string verificationId, ForceResendingToken forceResendingToken)
delegate void
Callback used when a verification code is sent to the given number.
Dispose()
void
GetCredential(string verificationId, string verificationCode)
Generate a credential for the given phone number.
VerificationCompleted(Credential credential)
delegate void
Callback used when phone number auto-verification succeeded.
VerificationFailed(string error)
delegate void
Callback used when phone number verification fails.
VerifyPhoneNumber(string phoneNumber, uint autoVerifyTimeOutMs, ForceResendingToken forceResendingToken, VerificationCompleted verificationCompleted, VerificationFailed verificationFailed)
void
Start the phone number authentication operation.
VerifyPhoneNumber(string phoneNumber, uint autoVerifyTimeOutMs, ForceResendingToken forceResendingToken, VerificationCompleted verificationCompleted, VerificationFailed verificationFailed, CodeSent codeSent)
void
Start the phone number authentication operation.
VerifyPhoneNumber(string phoneNumber, uint autoVerifyTimeOutMs, ForceResendingToken forceResendingToken, VerificationCompleted verificationCompleted, VerificationFailed verificationFailed, CodeAutoRetrievalTimeOut codeAutoRetrievalTimeOut)
void
Start the phone number authentication operation.
VerifyPhoneNumber(string phoneNumber, uint autoVerifyTimeOutMs, ForceResendingToken forceResendingToken, VerificationCompleted verificationCompleted, VerificationFailed verificationFailed, CodeSent codeSent, CodeAutoRetrievalTimeOut codeAutoRetrievalTimeOut)
void
Start the phone number authentication operation.

Public static functions

GetInstance(FirebaseAuth auth)
Return the PhoneAuthProvider for the specified auth.

Properties

MaxTimeoutMs

static uint MaxTimeoutMs

Maximum value of autoVerifyTimeOutMs in VerifyPhoneNumber.

VerifyPhoneNumber will automatically clamp values to this amount.

Public functions

CodeAutoRetrievalTimeOut

delegate void CodeAutoRetrievalTimeOut(
  string verificationId
)

Callback used when a timeout occurs.

CodeSent

delegate void CodeSent(
  string verificationId,
  ForceResendingToken forceResendingToken
)

Callback used when a verification code is sent to the given number.

Dispose

void Dispose()

GetCredential

Credential GetCredential(
  string verificationId,
  string verificationCode
)

Generate a credential for the given phone number.

Details
Parameters
verification_id
The id returned when sending the verification code. Sent to the caller via Listener::OnCodeSent.
verification_code
The verification code supplied by the user, most likely by a GUI where the user manually enters the code received in the SMS sent by VerifyPhoneNumber.
Returns

VerificationCompleted

delegate void VerificationCompleted(
  Credential credential
)

Callback used when phone number auto-verification succeeded.

VerificationFailed

delegate void VerificationFailed(
  string error
)

Callback used when phone number verification fails.

VerifyPhoneNumber