UNPKG

voluptasmollitia

Version:
45 lines (27 loc) 1.88 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@firebase/auth](./auth.md) &gt; [signInWithPhoneNumber](./auth.signinwithphonenumber.md) ## signInWithPhoneNumber() function Asynchronously signs in using a phone number. <b>Signature:</b> ```typescript export declare function signInWithPhoneNumber(auth: Auth, phoneNumber: string, appVerifier: ApplicationVerifier): Promise<ConfirmationResult>; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | | auth | [Auth](./auth.auth.md) | The Auth instance. | | phoneNumber | string | The user's phone number in E.164 format (e.g. +16505550101). | | appVerifier | [ApplicationVerifier](./auth.applicationverifier.md) | The [ApplicationVerifier](./auth.applicationverifier.md)<!-- -->. | <b>Returns:</b> Promise&lt;[ConfirmationResult](./auth.confirmationresult.md)<!-- -->&gt; ## Remarks This method sends a code via SMS to the given phone number, and returns a [ConfirmationResult](./auth.confirmationresult.md)<!-- -->. After the user provides the code sent to their phone, call [ConfirmationResult.confirm()](./auth.confirmationresult.confirm.md) with the code to sign the user in. For abuse prevention, this method also requires a [ApplicationVerifier](./auth.applicationverifier.md)<!-- -->. This SDK includes a reCAPTCHA-based implementation, [RecaptchaVerifier](./auth.recaptchaverifier.md)<!-- -->. ## Example ```javascript // 'recaptcha-container' is the ID of an element in the DOM. const applicationVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container'); const confirmationResult = await signInWithPhoneNumber(auth, phoneNumber, applicationVerifier); // Obtain a verificationCode from the user. const credential = await confirmationResult.confirm(verificationCode); ```