internal async Task OnIncomingPayload(NotificationPayload payload) { if(payload == null) return; if(App.CurrentAthlete == null) { _shelvedPayload = payload; return; } string challengeId; if(payload.Payload.TryGetValue("challengeId", out challengeId)) { try { var vm = new BaseViewModel(); var task = AzureService.Instance.GetChallengeById(challengeId); await vm.RunSafe(task); var details = new ChallengeDetailsPage(task.Result); details.AddDoneButton(); await App.Current.MainPage.Navigation.PushModalAsync(details.GetNavigationPage()); } catch(Exception e) { Insights.Report(e); Console.WriteLine(e); } } }
/// <summary> /// All application exceptions should be routed through this method so they get process/displayed to the user in a consistent manner /// </summary> void OnAppExceptionOccurred(BaseViewModel viewModel, Exception exception) { Device.BeginInvokeOnMainThread(async() => { try { if(_hud != null) { _hud.Dismiss(); } var msg = exception.Message; var mse = exception as MobileServiceInvalidOperationException; if(mse != null) { var body = await mse.Response.Content.ReadAsStringAsync(); var dict = JsonConvert.DeserializeObject<Dictionary<string, object>>(body); if(dict != null && dict.ContainsKey("message")) msg = dict["message"].ToString(); } if(msg.Length > 300) msg = msg.Substring(0, 300); msg.ToToast(ToastNotificationType.Error, "Uh oh"); } catch(Exception e) { Debug.WriteLine(e); } }); }
public Busy(BaseViewModel viewModel) { _viewModel = viewModel; Device.BeginInvokeOnMainThread(() => { lock(_sync) { _viewModel.IsBusy = true; } }); }