/*****************************************************************/
        // METHODS
        /*****************************************************************/
        #region Methods

        /// <summary>
        /// Verify phone no.
        /// </summary>
        /// <param name="callBack">Callback for PCL</param>
        /// <param name="phoneNo">Phone no. to verify</param>
        /// <returns></returns>
        public Task <FirebaseResponse> VerifyPhoneNo(IFirebaseServiceCallBack callBack, string phoneNo)
        {
            this.FirebaseServiceCallBack = callBack;

            try
            {
                // Check if phone no. is white listed
                WhiteListedPhoneNo = FirebaseService.CheckForTestPhoneNo(phoneNo);
                // Verify phone no.
                PhoneAuthProvider.Instance.VerifyPhoneNumber(
                    phoneNo,
                    60,
                    TimeUnit.Seconds,
                    Activity,
                    this
                    );
                // Return response
                return(new Task <FirebaseResponse>(() => new FirebaseResponse(true)));
            }
            catch (Exception mes)
            {
                // Return exception
                return(new Task <FirebaseResponse>(() => new FirebaseResponse(mes.Message)));
            }
        }
Exemple #2
0
        /// <summary>
        /// Verify phone no.
        /// </summary>
        /// <param name="callBack">Callback for PCL</param>
        /// <param name="phoneNo">Phone no. to verify</param>
        /// <returns>A firebase response</returns>
        public Task <FirebaseResponse> VerifyPhoneNo(IFirebaseServiceCallBack callBack, string phoneNo)
        {
            this.FirebaseServiceCallBack = callBack;

            try
            {
                // Check if phone no. is white listed
                WhiteListedPhoneNo = FirebaseService.CheckForTestPhoneNo(phoneNo);
                // Verify phone no.
                PhoneAuthProvider.DefaultInstance.VerifyPhoneNumber(
                    phoneNo,
                    null,
                    (verificationId, error) =>
                {
                    if (error != null)
                    {
                        FirebaseServiceCallBack?.OnVerificationFailed(error.LocalizedDescription);
                        return;
                    }
                    else
                    {
                        // Save verification ID for future use
                        App.LocalDataService.SaveValue(nameof(LocalDataKeys.FirebaseAuthVerificationId), verificationId);

                        if (WhiteListedPhoneNo != null)
                        {
                            var response = SignIn(FirebaseServiceCallBack, verificationId, WhiteListedPhoneNo.Code).Result;
                            if (!response.Success)
                            {
                                FirebaseServiceCallBack?.OnVerificationFailed(response.ErrorMessage);
                            }
                        }
                        FirebaseServiceCallBack?.OnCodeSent(verificationId);
                    }
                }
                    );
                // Return response
                return(new Task <FirebaseResponse>(() => new FirebaseResponse(true)));
            }
            catch (Exception mes)
            {
                // Return exception
                return(new Task <FirebaseResponse>(() => new FirebaseResponse(mes.Message)));
            }
        }