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);
                    });
                });
            });
        }
        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 UpdateEmailPassword()
        {
            CreateAlert("Send Verification Code", "", new[] { "Email" }, (resultArr) =>
            {
                var email = resultArr[0];
                BaseProvider.SendVerifyCodeWithEmail(email, AGCVerifyCodeAction.SetPassword);

                CreateAlert("Update Email Password", "", 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.Email);

                    passwordReq.AddOnSuccessCallback((result) =>
                    {
                        Console.WriteLine("password update success");
                    });
                    passwordReq.AddOnFailureCallback((error) =>
                    {
                        Console.WriteLine("password update failed");
                    });
                });
            });
        }
Esempio n. 4
0
        internal static void SendVerifyCodeWithEmail(string email, AGCVerifyCodeAction action)
        {
            AGCVerifyCodeSettings setting    = new AGCVerifyCodeSettings(action, null, 30);
            HMFTask <NSObject>    verifyCode = AGCEmailAuthProvider.RequestVerifyCodeWithEmail(email, 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);
            });
        }
Esempio n. 5
0
        partial void AnonymousLogin(NSObject sender)
        {
            // sign in anonymously
            HMFTask <NSObject> signInAnonymously = AGCAuth.GetInstance().SignInAnonymously();

            signInAnonymously.AddOnSuccessCallback((result) =>
            {
                AGCSignInResult signInResult = result as AGCSignInResult;
                Console.WriteLine("AnonymousLogin success");
                OpenUserInfoView(signInResult.User);
            });
            signInAnonymously.AddOnFailureCallback((error) =>
            {
                Console.WriteLine("AnonymousLogin failed");
            });
        }
Esempio n. 6
0
        private void RegisterEmailAccount()
        {
            string email            = accountText.Text;
            string password         = passwordText.Text;
            string verificationCode = codeText.Text;
            // register email account
            HMFTask <NSObject> register = AGCAuth.GetInstance().CreateUserWithEmail(email, password, verificationCode);

            register.AddOnSuccessCallback((result) =>
            {
                AGCSignInResult user = result as AGCSignInResult;
                Console.WriteLine("Account register success");
                OpenUserInfoView(user.User);
            });
            register.AddOnFailureCallback((error) =>
            {
                Console.WriteLine("Email create failed");
            });
        }
Esempio n. 7
0
        private void RegisterPhoneAccount()
        {
            string countryCode      = "90";
            string phoneNumber      = accountText.Text;
            string password         = passwordText.Text;
            string verificationCode = codeText.Text;
            // register phone account
            HMFTask <NSObject> register = AGCAuth.GetInstance().CreateUserWithCountryCode(countryCode, phoneNumber, password, verificationCode);

            register.AddOnSuccessCallback((result) =>
            {
                AGCSignInResult user = result as AGCSignInResult;
                Console.WriteLine("account register success --- >" + user.User.DisplayName);
                OpenUserInfoView(user.User);
            });
            register.AddOnFailureCallback((error) =>
            {
                Console.WriteLine("account register failed-->" + error);
            });
        }
 private void UpdateEmail()
 {
     CreateAlert("Send Verification Code", "", new[] { "Email" }, (resultArr) =>
     {
         var email = resultArr[0];
         BaseProvider.SendVerifyCodeWithEmail(email, AGCVerifyCodeAction.RegisterLogin);
         CreateAlert("Update Email", "", new[] { "Email", "Verification Code" }, (updateArr) =>
         {
             var updatedEmail            = updateArr[0];
             var code                    = updateArr[1];
             HMFTask <NSObject> emailReq = AGCAuth.GetInstance().CurrentUser?.UpdateEmail(updatedEmail, code);
             emailReq.AddOnSuccessCallback((result) =>
             {
                 Console.WriteLine("email update success");
             });
             emailReq.AddOnFailureCallback((error) =>
             {
                 Console.WriteLine("email update failed");
             });
         });
     });
 }
Esempio n. 9
0
        private void SignIn(AGCAuthCredential credential)
        {
            if (credential != null)
            {
                HMFTask <NSObject> signIn = AGCAuth.GetInstance().SignIn(credential);

                signIn.AddOnSuccessCallback((result) =>
                {
                    AGCSignInResult user = result as AGCSignInResult;
                    Console.WriteLine("sign in success");
                    OpenUserInfoView(user.User);
                });
                signIn.AddOnFailureCallback((error) =>
                {
                    Console.WriteLine("sign in failed-->" + error);
                });
            }
            else
            {
                Console.WriteLine("no credential");
            }
        }
Esempio n. 10
0
        private void SignInWithCredential(AGCAuthCredential credential)
        {
            if (credential == null)
            {
                Console.WriteLine("no credential");
            }

            // send sign in request with credential
            HMFTask <NSObject> signIn = AGCAuth.GetInstance().SignIn(credential);

            signIn.AddOnSuccessCallback((result) =>
            {
                Console.WriteLine("Sign in success");
                OpenUserInfoView((result as AGCSignInResult).User);
            });
            signIn.AddOnFailureCallback((error) =>
            {
                Console.WriteLine("Sign in failed -->" + error);
            });

            Console.WriteLine("sign in failed");
        }