private Task <PhoneNumberVerificationResult> VerifyPhoneNumberAsync(Firebase.Auth.FirebaseAuth auth, IPhoneMultiFactorInfo phoneMultiFactorInfo, IMultiFactorSession multiFactorSession, TimeSpan timeout, bool?requiresSmsValidation = null) { var activity = CrossCurrentActivity.Current.Activity ?? throw new NullReferenceException("current activity is null"); var tcs = new TaskCompletionSource <PhoneNumberVerificationResult>(); var callbacks = new Callbacks(tcs); var builder = PhoneAuthOptions.NewBuilder(auth) .SetActivity(activity) .SetCallbacks(callbacks) .SetMultiFactorHint(phoneMultiFactorInfo.ToNative()) .SetMultiFactorSession(multiFactorSession.ToNative()) .SetTimeout(new Java.Lang.Long((long)timeout.TotalMilliseconds), TimeUnit.Milliseconds); if (requiresSmsValidation.HasValue) { builder.RequireSmsValidation(requiresSmsValidation.Value); } auth.FirebaseAuthSettings.SetAutoRetrievedSmsCodeForPhoneNumber(null, null); PhoneAuthProvider.VerifyPhoneNumber(builder.Build()); return(tcs.Task); }
private async Task <PhoneNumberVerificationResult> VerifyPhoneNumberAsync(Auth auth, IPhoneMultiFactorInfo phoneMultiFactorInfo, IMultiFactorSession multiFactorSession) { try { auth.Settings.AppVerificationDisabledForTesting = false; var verificationId = await PhoneAuthProvider.Create(auth) .VerifyPhoneNumberAsync(phoneMultiFactorInfo.ToNative(), FirebaseAuth.VerifyingPhoneNumberAuthUIDelegate, multiFactorSession.ToNative()) .ConfigureAwait(false); return(new PhoneNumberVerificationResult(null, verificationId)); } catch (NSErrorException e) { throw ExceptionMapper.Map(e); } }