async void MvpApiService_RequestErrorOccurred(object sender, Services.Helpers.ApiServiceEventArgs e) { if (e.IsBadRequest) { await DialogService.AlertAsync(Translations.error_badrequest, Translations.error_title, Translations.ok); } else if (e.IsServerError) { await DialogService.AlertAsync(Translations.error_servererror, Translations.error_title, Translations.ok); } }
async void MvpApiService_RequestErrorOccurred(object sender, Services.Helpers.ApiServiceEventArgs e) { if (e.IsBadRequest) { await dialogService.AlertAsync( "That request wasn't quite right. Try again later.", "Oh boy, that's not good!", "OK"); } else if (e.IsServerError) { await dialogService.AlertAsync( "The MVP API messed something up. Couldn't grab that data right now.", "Oh boy, that's not good!", "OK"); } }
/// <summary> /// Handles expired access tokens. /// </summary> async void MvpApiService_AccessTokenExpired(object sender, Services.Helpers.ApiServiceEventArgs e) { // If the access token expired, we need to sign in again, // because we might've lost our auth. var result = await AuthService.SignInAsync(); if (!result) { // Show a message that data could not be refreshed. Also forward the user back to getting started // telling the user that a logout has occurred. await DialogService.AlertAsync(Translations.alert_error_unauthorized, Translations.error_title, Translations.ok); // Move the user over to Getting Started. await AuthService.SignOutAsync(); var navHelper = Resolver.Resolve <INavigationHelper>(); navHelper.SetRootView(nameof(IntroPage)); } }
async void MvpApiService_AccessTokenExpired(object sender, Services.Helpers.ApiServiceEventArgs e) { // If the access token expired, we need to sign in again, // because we might've lost our auth. var result = await authService.SignInAsync(); if (!result) { // Show a message that data could not be refreshed. Also forward the user back to getting started // telling the user that a logout has occurred. await dialogService.AlertAsync( "Your credentials have expired. We needed to log you out. Please login again to continue.", "Oh boy, that's not good!", "OK"); // Move the user over to Getting Started. await authService.SignOutAsync(); var navHelper = Resolver.Resolve <INavigationHelper>(); navHelper.SetRootView(nameof(IntroPage)); } }