private void UpdatePhone()
        {
            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("Update Phone", "", new[] { "Country code", "Phone number", "Verification Code" }, (updateArr) =>
                {
                    countryCode = updateArr[0];
                    phoneNumber = updateArr[1];
                    var code    = updateArr[2];

                    // update the phone number of the current user
                    HMFTask <NSObject> phoneReq = AGCAuth.GetInstance().CurrentUser?.UpdatePhoneWithCountryCode(countryCode, phoneNumber, code);

                    phoneReq.AddOnSuccessCallback((result) =>
                    {
                        Console.WriteLine("phone update success");
                    });
                    phoneReq.AddOnFailureCallback((error) =>
                    {
                        Console.WriteLine("phone update failed");
                    });
                });
            });
        }
        private void UpdatePhonePassword()
        {
            CreateAlert("Send Verification Code", "", new[] { "Country code", "Phone number" }, (resultArr) =>
            {
                var countryCode = resultArr[0];
                var phoneNumber = resultArr[1];
                BaseProvider.SendVerifyCodeWithCountryCode(countryCode, phoneNumber, AGCVerifyCodeAction.SetPassword);
                CreateAlert("Update Phone Password", "", new[] { "New Password", "Verification Code" }, (updateArr) =>
                {
                    var password = updateArr[0];
                    var code     = updateArr[1];

                    // update the password of the current user
                    HMFTask <NSObject> passwordReq = AGCAuth.GetInstance().CurrentUser?.UpdatePassword(password, code, (int)AGCAuthProviderType.Phone);

                    passwordReq.AddOnSuccessCallback((result) =>
                    {
                        Console.WriteLine("password update success");
                    });
                    passwordReq.AddOnFailureCallback((error) =>
                    {
                        Console.WriteLine("password update failed--" + error);
                    });
                });
            });
        }
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");
                    });
                });
            });
        }