Saltar al contenido

flutter firebase auth establece ejemplo de código de número de teléfono

Estuvimos indagado en todo el mundo online para de este modo tener para ti la respuesta para tu duda, si tienes inquietudes deja la duda y contestamos sin falta.

Ejemplo: autenticación de teléfono firebase flutter

Future<void> _submitPhoneNumber() async 
    /// NOTE: Either append your phone number country code or add in the code itself
    /// Since I'm in India we use "+91 " as prefix `phoneNumber`
    String phoneNumber = "+91 " + _phoneNumberController.text.toString().trim();
    print(phoneNumber);

    /// The below functions are the callbacks, separated so as to make code more readable
    void verificationCompleted(AuthCredential phoneAuthCredential) 
      print('verificationCompleted');
      ...
      this._phoneAuthCredential = phoneAuthCredential;
      print(phoneAuthCredential);
    

    void verificationFailed(AuthException error) 
      ...
      print(error);
    

    void codeSent(String verificationId, [int code]) 
      ...
      print('codeSent');
    

    void codeAutoRetrievalTimeout(String verificationId) 
      ...
      print('codeAutoRetrievalTimeout');
    

    await FirebaseAuth.instance.verifyPhoneNumber(
      /// Make sure to prefix with your country code
      phoneNumber: phoneNumber,

      /// `seconds` didn't work. The underlying implementation code only reads in `milliseconds`
      timeout: Duration(milliseconds: 10000),

      /// If the SIM (with phoneNumber) is in the current device this function is called.
      /// This function gives `AuthCredential`. Moreover `login` function can be called from this callback
      verificationCompleted: verificationCompleted,

      /// Called when the verification is failed
      verificationFailed: verificationFailed,

      /// This is called after the OTP is sent. Gives a `verificationId` and `code`
      codeSent: codeSent,

      /// After automatic code retrival `tmeout` this function is called
      codeAutoRetrievalTimeout: codeAutoRetrievalTimeout,
    ); // All the callbacks are above
  

Sección de Reseñas y Valoraciones

Si estás contento con lo expuesto, tienes la habilidad dejar una reseña acerca de qué le añadirías a este post.

¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)



Utiliza Nuestro Buscador

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *