动态口令自动填充的Firebase身份验证中是否需要SMS Retriever API? [英] Does SMS Retriever API is required in Firebase authentication for otp auto fill?

查看:0
本文介绍了动态口令自动填充的Firebase身份验证中是否需要SMS Retriever API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Firebase auth api验证用户电话号码。目前在我的情况下,我有一个屏幕上,用户输入电话号码和第二个屏幕上的动态口令。根据文档firebase,大部分时间会自动检索动态口令并启动验证过程。 所以我的问题是它已经在Firebase Auth SDK中实现了SMS Retriever API,或者我应该自己实现它来检索短信和自动填充动态口令。

推荐答案

否。我们不需要管理短信检索方案。

如果设备包含相同的SIM卡,则由onVerificationCompleted(PhoneAuthCredential phoneAuthCredential)方法中的PhoneAuthProvider.OnVerificationStateChangedCallbacks自动管理。

片段:

private PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {

        @Override
        public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
            Toast.makeText(FCMsmsTest.this, "onVerificationCompleted " + phoneAuthCredential.toString(), Toast.LENGTH_SHORT).show();
            signInWithPhoneAuthCredential(phoneAuthCredential);
        }

        @Override
        public void onVerificationFailed(FirebaseException e) {
            Toast.makeText(FCMsmsTest.this, "onVerificationFailed " + e.toString(), Toast.LENGTH_SHORT).show();

            if (e instanceof FirebaseAuthInvalidCredentialsException) {
                Toast.makeText(FCMsmsTest.this, "Invalid Request " + e.toString(), Toast.LENGTH_SHORT).show();
            } else if (e instanceof FirebaseTooManyRequestsException) {
                Toast.makeText(FCMsmsTest.this, "The SMS quota for the project has been exceeded " + e.toString(), Toast.LENGTH_SHORT).show();
            }
        }

        @Override
        public void onCodeSent(String verificationId,
                               PhoneAuthProvider.ForceResendingToken token) {
            Toast.makeText(FCMsmsTest.this, "onCodeSent " + verificationId, Toast.LENGTH_SHORT).show();
            editText.setText("");

            mVerificationId = verificationId;
            PhoneAuthProvider.ForceResendingToken mResendToken = token;

            showDialog();
        }
    };

这篇关于动态口令自动填充的Firebase身份验证中是否需要SMS Retriever API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆