Задать вопрос
@egorchikJava

Как решить проблему с регистрацией по номеру firebase?

Пытаюсь зарегистрироваться по номеру телефона и выдает ошибку
E/FirebearCryptoHelper: Exception encountered during crypto setup:
    Protocol message contained an invalid tag (zero).
E/FirebearCryptoHelper: KeysetManager failed to initialize - unable to get Public key
E/RecaptchaActivity: Could not generate an encryption key for reCAPTCHA - cancelling flow.
W/Activity: Slow Operation: Activity mychati.app/com.google.firebase.auth.internal.RecaptchaActivity onResume took 180ms
W/System: Ignoring header X-Firebase-Locale because its value was null.
E/zzf: Failed to get reCAPTCHA token with error [An internal error has occurred. [ Failed to generate/retrieve public encryption key for reCAPTCHA flow. ]]- calling backend without app verification
I/AssistStructure: Flattened final assist data: 2196 bytes, containing 1 windows, 11 views
W/System: Ignoring header X-Firebase-Locale because its value was null.
E/FirebaseAuth: [SmsRetrieverHelper] SMS verification code request failed: unknown status code: 17010 null
D/CompatibilityChangeReporter: Compat change id reported: 147798919; UID 10749; state: ENABLED


Добавлены отпечатки SHA1 и SHA 256, загружена последняя версия Google-Service Json. Вот мой код регистрации
private String verificationID;
private AppCompatButton getcode,verifycode;
private FirebaseAuth mAuth;
    private PhoneAuthProvider.ForceResendingToken mResendToken;
private static int PHONE_NUMBER=12;
  edit_phonenum.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void afterTextChanged(Editable editable) {
                if (editable.length()==PHONE_NUMBER){
                    getcode.setEnabled(true);

                }else{
                    getcode.setEnabled(false);
                }
            }
        });
  getcode.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              String  phoneNumber=edit_phonenum.getText().toString();
PhoneVery(phoneNumber);

verifycode.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        verifycode(verifysms.getText().toString());
    }
});
            }
        });
    }

    private void PhoneVery(String phoneNumber) {
        PhoneAuthOptions options =
                PhoneAuthOptions.newBuilder(mAuth)
                        .setPhoneNumber(phoneNumber)       // Phone number to verify
                        .setTimeout(60L, TimeUnit.SECONDS) // Timeout and unit
                        .setActivity(RegisterPhoneActivity.this)                 // Activity (for callback binding)
                        .setCallbacks(mCallbacks)          // OnVerificationStateChangedCallbacks
                        .build();
        PhoneAuthProvider.verifyPhoneNumber(options);
    }

    private PhoneAuthProvider.OnVerificationStateChangedCallbacks
            mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
        @Override
        public void onVerificationCompleted(@NonNull PhoneAuthCredential credential)
        {
            final String code = credential.getSmsCode();
            if(code!=null)
            {
                verifycode(code);
            }
        }
        @Override
        public void onVerificationFailed(@NonNull FirebaseException e) {
            Toast.makeText(RegisterPhoneActivity.this, "Verification Failed", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onCodeSent(@NonNull String s,
                               @NonNull PhoneAuthProvider.ForceResendingToken token)
        {
            super.onCodeSent(s, token);
            verificationID = s;
            Toast.makeText(RegisterPhoneActivity.this, "Код отправлен", Toast.LENGTH_SHORT).show();
            verifycode.setEnabled(true);
verifycode.setVisibility(View.VISIBLE);
verifysms.setVisibility(View.VISIBLE);
getcode.setEnabled(false);
getcode.setVisibility(View.GONE);
        }};
    private void verifycode(String Code)
    {
        PhoneAuthCredential credential = PhoneAuthProvider.getCredential(verificationID,Code);
        signinbyCredentials(credential);
    }

    private void signinbyCredentials(PhoneAuthCredential credential)
    {
        FirebaseAuth firebaseAuth = FirebaseAuth.getInstance();
        firebaseAuth.signInWithCredential(credential)
                .addOnCompleteListener(new OnCompleteListener() {
                    @Override
                    public void onComplete(@NonNull Task task)
                    {
                        if(task.isSuccessful())
                        {

                           Intent sucsees=new Intent(RegisterPhoneActivity.this, SplashScreenActivity.class);

                           startActivity(sucsees);
                           finish();
                        }

                    }
                });}

в самом приложении срабатывает метод onVerificationFailed и выдает тост ""Verification Failed""
  • Вопрос задан
  • 303 просмотра
Подписаться 1 Простой Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы