async void Init() { new LanguageService().SetLanguage(); if (Settings.IsLoggedIn) { var storeManager = new BasePageModel().StoreManager; if (StoreManager.NeedsTokenRefresh()) { var isRefreshed = await storeManager.RegenerateToken(); if (isRefreshed) { if (Settings.HasToCompleteChat) { // open chat var page = FreshPageModelResolver.ResolvePageModel <ChatPageModel>(); MainPage = new FreshNavigationContainer(page); } else { await storeManager.UserStore.UpdateCurrentUser(null); MainPage = TabNavigator.GenerateTabPage(); } } else { var page = FreshPageModelResolver.ResolvePageModel <TutorialPageModel>(); MainPage = new FreshNavigationContainer(page); } } else { if (Settings.HasToCompleteChat) { // open chat var page = FreshPageModelResolver.ResolvePageModel <ChatPageModel>(); MainPage = new FreshNavigationContainer(page); } else { await storeManager.UserStore.UpdateCurrentUser(null); MainPage = TabNavigator.GenerateTabPage(); } } UpdateSubscription(); } else { var page = FreshPageModelResolver.ResolvePageModel <TutorialPageModel>(); MainPage = new FreshNavigationContainer(page); } }
async void Init() { if (storeManager == null) { return; } if (!storeManager.IsInitialized) { await storeManager.InitializeAsync(); } //verify Token await storeManager.VerifyTokenAsync(); if (StoreManager.MobileService.CurrentUser == null) { Device.BeginInvokeOnMainThread(() => { var page = FreshPageModelResolver.ResolvePageModel <LoginPageModel>(); var container = new FreshNavigationContainer(page) { BarTextColor = Color.Black }; MainPage = container; }); } else { Device.BeginInvokeOnMainThread(() => { var tabbedPage = TabNavigator.GenerateTabPage(); MainPage = tabbedPage; }); await storeManager.SyncAllAsync(true); } }