public async Task <bool> LoginUserAsync(string providerName) { var context = Android.App.Application.Context; if (!Enum.TryParse(providerName, out MobileServiceAuthenticationProvider provider)) { provider = MobileServiceAuthenticationProvider.Facebook; } var client = AzureClientUtility.GetClient(); // new MobileServiceClient(Constants.AzureServerUrl); try { var user = await client.LoginAsync(context, provider, LoginConfig.Constants.AzureClientSchema); Settings.LastValidToken = user?.MobileServiceAuthenticationToken ?? string.Empty; Settings.UID = user?.UserId ?? string.Empty; LoginConfig.Settings.LoginWithProvider = providerName; return(!string.IsNullOrWhiteSpace(Settings.LastValidToken)); } catch (Exception ex) { Debug.WriteLine(ex); throw; } }
public async Task <bool> LoginUserAsync(string providerName) { if (!Enum.TryParse(providerName, out MobileServiceAuthenticationProvider provider)) { provider = MobileServiceAuthenticationProvider.Facebook; } var client = AzureClientUtility.GetClient(); // new MobileServiceClient( Constants.AzureServerUrl ); AppDelegate.ResumeWithUrl = url => string.Equals(url.Scheme, LoginConfig.Constants.AzureClientSchema) && client.ResumeWithURL(url); try { var user = await client.LoginAsync(UIApplication.SharedApplication.KeyWindow.RootViewController, provider, LoginConfig.Constants.AzureClientSchema); Settings.LastValidToken = user?.MobileServiceAuthenticationToken ?? string.Empty; Settings.UID = user?.UserId ?? string.Empty; LoginConfig.Settings.LoginWithProvider = providerName; return(!string.IsNullOrWhiteSpace(Settings.LastValidToken)); } catch (Exception ex) { //Insights.Report(ex); Debug.WriteLine(ex); throw; } }