Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

App freezes after failed authentication.

$
0
0

Hi everyone,
I am using azure mobile app services with xamarin forms to build an app.
In my app, I use Facebook, Twitter, and Google to authenticate my users into the app.

My login page consists of three buttons (twitter, google, and facebook) to sign in, when pressing any button, the user is taken to a web page to continue the authentication procedure, which works fine if the user entered the correct credentials in the web page and returns successfully to my app.

However, if the user pressed one of the buttons, and then dismissed the web page, the app FREEZES completely. And there is no way to stop the freezing. I tried changing the current xamarin page, or removing it, but it seems like the whole app freezes, not just the current page.

Here is my authentication code in iOS AppDelegate:

public async Task<bool> Authenticate(MobileServiceAuthenticationProvider Provider)
        {
            var res = false;
            if (user == null)
            {
                //await Manager.DefaultManager.CurrentClient.LogoutAsync();
                try
                {
                    user = await Manager.DefaultManager
                                            .CurrentClient.LoginAsync(UIApplication.SharedApplication.KeyWindow.RootViewController.PresentedViewController,
                                                                                     Provider, "appscheme"
                                                                                    );

                    if (user == null)
                    {
                        res = false;
                    }
                    else
                    {
                        res = true;
                        var account = new Account(Manager.DefaultManager.CurrentClient.CurrentUser.UserId);
                        account.Properties.Add("token", Manager.DefaultManager.CurrentClient.CurrentUser.MobileServiceAuthenticationToken);

                        await SecureStorageAccountStore.SaveAsync(account, "user");
                    }

                }
                catch (Exception e)
                {
                    Debug.WriteLine("Login Status: " + e.Message);
                }
            }

            return res;
        }

Is there a way to prevent the app from freezing in case of a failed login attempt?


Viewing all articles
Browse latest Browse all 204402


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>