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");
                    });
                });
            });
        }
        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);
                    });
                });
            });
        }
示例#4
0
 public override void ViewDidAppear(bool animated)
 {
     base.ViewDidAppear(animated);
     if (AGCAuth.GetInstance().CurrentUser != null)
     {
         OpenUserInfoView(AGCAuth.GetInstance().CurrentUser);
     }
 }
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);
            // Get the currently logged-in user
            var user = AGCAuth.GetInstance().CurrentUser;

            RefreshView(user);
        }
示例#6
0
        void UnLinkAccount(AGCAuthProviderType type)
        {
            var unLinkReq = AGCAuth.GetInstance().CurrentUser?.Unlink(type);

            unLinkReq.AddOnSuccessCallback((result) =>
            {
                Console.WriteLine("unlink success");
                owner.RefreshLinkState();
            });
            unLinkReq.AddOnFailureCallback((error) =>
            {
                Console.WriteLine("unlink failed");
            });
        }
示例#7
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");
            });
        }
示例#8
0
        public void RefreshLinkState()
        {
            var providers = AGCAuth.GetInstance().CurrentUser.ProviderInfo;

            if (providers != null)
            {
                foreach (var item in providers)
                {
                    string itemProvider = item["provider"].ToString();
                    int    pr           = Convert.ToInt32(itemProvider);
                    if (linkAccounts.FirstOrDefault(a => a.ProviderType == pr) is LinkItem lItem)
                    {
                        lItem.IsLinked = true;
                    }
                }
            }
        }
示例#9
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");
            });
        }
        public SettingsTableSource(SettingsViewController owner)
        {
            this.owner = owner;

            var currentProvider = AGCAuth.GetInstance().CurrentUser?.ProviderId;

            if (currentProvider == AGCAuthProviderType.Email)
            {
                tableItems = new string[] { "Update User Profile", "Update Email", "Update Email Password" };
            }
            else if (currentProvider == AGCAuthProviderType.Phone)
            {
                tableItems = new string[] { "Update User Profile", "Update Phone", "Update Phone Password" };
            }
            else
            {
                tableItems = new string[] { "Update User Profile" };
            }
        }
示例#11
0
 void LinkAccount(AGCAuthCredential credential)
 {
     if (credential != null)
     {
         var linkReq = AGCAuth.GetInstance().CurrentUser?.Link(credential);
         linkReq.AddOnSuccessCallback((result) =>
         {
             Console.WriteLine("link success");
             owner.RefreshLinkState();
         });
         linkReq.AddOnFailureCallback((error) =>
         {
             Console.WriteLine("link failed-->" + error);
         });
     }
     else
     {
         Console.WriteLine("link failed");
     }
 }
        private void UpdateProfile()
        {
            CreateAlert("Update Profile", "", new[] { "DisplayName", "PhotoUrl" }, (resultArr) =>
            {
                var request         = new AGCProfileRequest();
                request.DisplayName = resultArr[0];
                request.PhotoUrl    = resultArr[1];
                // update the profile of the current user
                var profileReq = AGCAuth.GetInstance().CurrentUser?.UpdateProfile(request);

                profileReq.AddOnSuccessCallback((result) =>
                {
                    Console.WriteLine("profile update success");
                });
                profileReq.AddOnFailureCallback((error) =>
                {
                    Console.WriteLine("profile update failed");
                });
            });
        }
示例#13
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);
            });
        }
示例#14
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");
        }
 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");
             });
         });
     });
 }
示例#16
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");
                    });
                });
            });
        }
示例#17
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");
            }
        }
示例#18
0
        private void LinkEmailAccount()
        {
            CreateAlert("Send Verification Code", "", new[] { "Email" }, (resultArr) =>
            {
                var email = resultArr[0];
                BaseProvider.SendVerifyCodeWithEmail(email, AGCVerifyCodeAction.RegisterLogin);

                CreateAlert("Link Email Account", "", new[] { "Email", "Password", "Verification Code" }, (linkArr) =>
                {
                    email        = linkArr[0];
                    var password = linkArr[1];
                    var code     = linkArr[2];
                    AGCAuthCredential credential;
                    if (string.IsNullOrEmpty(code))
                    {
                        // Generate a credential to link to email account with password
                        credential = AGCEmailAuthProvider.CredentialWithEmail(email, password: password);
                    }
                    else
                    {
                        // Generate a credential to link to email account with verification code
                        credential = AGCEmailAuthProvider.CredentialWithEmail(email, password: password, code);
                    }

                    var linkReq = AGCAuth.GetInstance().CurrentUser?.Link(credential);

                    linkReq.AddOnSuccessCallback((result) =>
                    {
                        Console.WriteLine("link success");
                        owner.RefreshLinkState();
                    });
                    linkReq.AddOnFailureCallback((error) =>
                    {
                        Console.WriteLine("link failed");
                    });
                });
            });
        }
 partial void DeleteUser_Clicked(NSObject sender)
 {
     AGCAuth.GetInstance().DeleteUser();
     Console.WriteLine("user deleted");
     this.DismissModalViewController(true);
 }
 partial void SignOut_Clicked(NSObject sender)
 {
     AGCAuth.GetInstance().SignOut();
     Console.WriteLine("sign out");
     this.NavigationController.PopViewController(true);
 }