Ejemplo n.º 1
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);
            });
        }
Ejemplo n.º 2
0
        private void EmailLogin()
        {
            AGCAuthCredential credential;
            string            email            = accountText.Text;
            string            password         = passwordText.Text;
            string            verificationCode = codeText.Text;

            if (codeText.Text.Length == 0)
            {
                // Generate a credential to sign in to email account with password
                credential = AGCEmailAuthProvider.CredentialWithEmail(email, password);
            }
            else
            {
                // Generate a credential to sign in to email account with verification code
                credential = AGCEmailAuthProvider.CredentialWithEmail(email, password, verificationCode);
            }
            SignInWithCredential(credential);
        }
Ejemplo n.º 3
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");
                    });
                });
            });
        }