public async void WidgetPerformUpdate(Action <NCUpdateResult> completionHandler) { // Perform any setup necessary in order to update the view. // If an error is encoutered, use NCUpdateResultFailed // If there's no update required, use NCUpdateResultNoData // If there's an update, use NCUpdateResultNewData eventTitle.Text = string.Empty; eventDescription.Text = string.Empty; try { var locationManager = new CoreLocation.CLLocationManager(); var location = locationManager.Location; var service = new ReactorToday.Shared.Services.EventsService(); var events = await service.GetTodaysEventsAsync(); var firstEvent = events.FirstOrDefault(); eventTitle.Text = firstEvent.Title; eventDescription.Text = firstEvent.EventDescription; completionHandler(NCUpdateResult.NewData); } catch (Exception) { eventTitle.Text = "I'm sorry I've croaked."; completionHandler(NCUpdateResult.Failed); } }
public async void PerformFetch(UIApplication application, Action <UIBackgroundFetchResult> completionHandler) { List <Event> Events = new List <Event>(); try { var service = new ReactorToday.Shared.Services.EventsService(); Events = await service.GetTodaysEventsAsync(); MonkeyCache.LiteDB.Barrel.Current.Add <List <Event> >("events", Events, TimeSpan.FromHours(RefreshInterval)); completionHandler(UIBackgroundFetchResult.NewData); } catch (Exception) { completionHandler(UIBackgroundFetchResult.Failed); } }