Beispiel #1
0
        internal static void SendVerifyCodeWithCountryCode(string countryCode, string phoneNumber, AGCVerifyCodeAction action)
        {
            AGCVerifyCodeSettings setting    = new AGCVerifyCodeSettings(action, null, 30);
            HMFTask <NSObject>    verifyCode = AGCPhoneAuthProvider.RequestVerifyCodeWithCountryCode(countryCode, phoneNumber, setting);

            verifyCode.AddOnSuccessCallback((result) =>
            {
                AGCVerifyCodeResult code = result as AGCVerifyCodeResult;
                Console.WriteLine("Verification code created successfully.");
                CreateAlert();
            });
            verifyCode.AddOnFailureCallback((error) =>
            {
                Console.WriteLine("Verification code created failed." + error);
            });
        }
        private void PhoneLogin()
        {
            AGCAuthCredential credential;
            string            countryCode      = "90";
            string            phoneNumber      = accountText.Text;
            string            password         = passwordText.Text;
            string            verificationCode = codeText.Text;

            if (codeText.Text.Length == 0)
            {
                // Generate a credential to sign in phone account with password
                credential = AGCPhoneAuthProvider.CredentialWithCountryCode(countryCode, phoneNumber, password);
            }
            else
            {
                // Generate a credential to sign in phone account with verification code
                credential = AGCPhoneAuthProvider.CredentialWithCountryCode(countryCode, phoneNumber, password, verificationCode);
            }
            SignInWithCredential(credential);
        }
Beispiel #3
0
        private void LinkPhoneAccount()
        {
            CreateAlert("Send Verification Code", "", new[] { "Country code", "Phone number" }, (resultArr) =>
            {
                var countryCode = resultArr[0];
                var phoneNumber = resultArr[1];
                BaseProvider.SendVerifyCodeWithCountryCode(countryCode, phoneNumber, AGCVerifyCodeAction.RegisterLogin);
                CreateAlert("Link Phone Account", "", new[] { "Country code", "Phone number", "Password", "verification code" }, (updateArr) =>
                {
                    countryCode  = resultArr[0];
                    phoneNumber  = resultArr[1];
                    var password = updateArr[2];
                    var code     = updateArr[3];
                    AGCAuthCredential credential;
                    if (string.IsNullOrEmpty(code))
                    {
                        // Generate a credential to link phone account with password
                        credential = AGCPhoneAuthProvider.CredentialWithCountryCode(countryCode, phoneNumber, password);
                    }
                    else
                    {
                        // Generate a credential to link phone account with verification code
                        credential = AGCPhoneAuthProvider.CredentialWithCountryCode(countryCode, phoneNumber, password, code);
                    }
                    // link phone account with credential
                    var linkReq = AGCAuth.GetInstance().CurrentUser?.Link(credential);

                    linkReq.AddOnSuccessCallback((result) =>
                    {
                        Console.WriteLine("link success");
                        owner.RefreshLinkState();
                    });
                    linkReq.AddOnFailureCallback((error) =>
                    {
                        Console.WriteLine("link failed");
                    });
                });
            });
        }