Проверка подлинности телефона Firebase на Xamarin.Form - PullRequest
0 голосов
/ 20 июня 2020

Я настроил Firebase Phone Auth в своем приложении. Но возникла проблема: СМС не приходит на номер, который используется в телефоне. Если отправить смс на другой номер, то все нормально работает. В чем причина этой проблемы? Ниже приведены классы, реализующие обратный вызов Phone Auth My auth:

public class AuthCallbacks : PhoneAuthProvider.OnVerificationStateChangedCallbacks
{

    public override void OnVerificationCompleted(PhoneAuthCredential credential)
    {
        try
        {
            string smsCode = credential.SmsCode;
            System.Diagnostics.Debug.WriteLine("onVerificationCompleted " + smsCode);
            System.Diagnostics.Debug.WriteLine("onVerificationCompleted " + credential);
        }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine(ex);
        }
    }

    public override void OnVerificationFailed(FirebaseException exception)
    {
        System.Diagnostics.Debug.WriteLine("onVerificationFailed: " + exception);
    }

    public override void OnCodeSent(string verificationId, PhoneAuthProvider.ForceResendingToken forceResendingToken)
    {
        try
        {
            base.OnCodeSent(verificationId, forceResendingToken);
            VerifyCode.Code = verificationId;
            System.Diagnostics.Debug.WriteLine("onCodeSent " + verificationId);
        }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine(ex);
        }
    }
}

}

мой класс Authenticator

 public class Authenticator : IAuthentication
{
    string verificationID;
    public void RegsiterWithPhoneNumber(string phoneNumber)
    {
        try
        {
            verificationID = PhoneAuthProvider.DefaultInstance.VerifyPhoneNumberAsync(phoneNumber, null).Result;
            System.Diagnostics.Debug.WriteLine("VerifyPhoneNumber");
        }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine(ex);
        }
    }
    public void VerifySignInCode(string code, INavigation Navigation)
    {
        System.Diagnostics.Debug.WriteLine("VerifySignInCode");
        PhoneAuthCredential credential = PhoneAuthProvider.DefaultInstance.GetCredential(verificationID, code);
        System.Diagnostics.Debug.WriteLine(credential);
        SignInWithPhoneAuthCredential(credential);
        Navigation.PushAsync(new ProfilePage());
    }

    private async void SignInWithPhoneAuthCredential(PhoneAuthCredential credential)
    {
        try
        {
            await Auth.DefaultInstance.SignInWithCredentialAsync(credential);

        }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine(ex);
        }
    }

    
}
...