verifyOtp method

Future<FirebaseAuthenticationResult> verifyOtp(
  1. ConfirmationResult confirmationResult,
  2. String otp
)

Verify SMS code using confirmationResult and otp

Web Platform support

Implementation

Future<FirebaseAuthenticationResult> verifyOtp(
    ConfirmationResult confirmationResult, String otp) async {
  try {
    UserCredential userCredential = await confirmationResult.confirm(otp);
    return FirebaseAuthenticationResult(user: userCredential.user);
  } catch (e) {
    throw FirebaseAuthenticationResult.error(
      errorMessage:
          'We could not verify the otp at this time. Please try again.',
      exceptionCode: e.toString(),
    );
  }
}