In forms xamarin, RootPage with the layout of the main layouts. My task is to display this page after a user has successfully logged in. I am using azure mobile service to login. I spend more time to get the result. I saw some other solutions, but this solution does not display the main details as expected. Finally, I got a solution.
Here is the code in app.cs
public App() { Client = new MobileServiceClient("your azure url", "your master key"); LoadMainPage(); } public void LoadMainPage() { if (Client.CurrentUser == null) { MainPage=new NavigationPage(new SplashPage()); } else { MainPage = new RootView();; } }
On the login page
async void OnLoginClicked(object sender, EventArgs args) { MobileServiceUser user; try { user = await DependencyService.Get<IMobileClient>().LoginAsync(MobileServiceAuthenticationProvider.Facebook); Application.Current.MainPage=new RootView(); await Navigation.PopToRootAsync(); } catch (InvalidOperationException ex) { if (ex.Message.Contains("Authentication was cancelled")) {
source share