public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { UIApplication.SharedApplication.SetMinimumBackgroundFetchInterval(UIApplication.BackgroundFetchIntervalMinimum); NSLogHelper.Write("BackgroundFetchDemo registered!"); var settings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound , null); UIApplication.SharedApplication.RegisterUserNotificationSettings(settings); return(true); }
public override void PerformFetch(UIApplication application, Action <UIBackgroundFetchResult> completionHandler) { NSLogHelper.Write($"BackgroundFetchDemo called PerformFetch at {{{DateTime.Now}}}"); if (!(Window.RootViewController is UINavigationController navigationController)) { NSLogHelper.Write("BackgroundFetchDemo top viewcontroller should be UINavigationController"); completionHandler(UIBackgroundFetchResult.Failed); return; } if (!(navigationController.TopViewController is DemoTableViewControler demoTableViewControler)) { NSLogHelper.Write("BackgroundFetchDemo should contains a DemoTableViewControler"); completionHandler(UIBackgroundFetchResult.Failed); return; } demoTableViewControler.InsertNewObjectForFetch(completionHandler); UIApplication.SharedApplication.ApplicationIconBadgeNumber += 1; }