56329

Background fetch execution time with iOS 10 UserNotifications without user interaction

In the Push Notification API before iOS 10, I could easily run a background job triggered by a Push Notification being received. Just received -- the user didn't have to interact with it at all. Now it seems in order for my same background jobs to be carried out with this new framework the user must interact with the notification somehow. Is there a way with this new framework to just run a background job when a certain push is just received by the client device, but not interacted with by the user? Can I pass a method in the push's user info dictionary?

Answer1:

I found a solution that doesn't work directly with the UserNotifications framework but still allows you to perform background jobs in iOS 10 via push notifications.

I found that by using the UIApplicationDelegate you can in fact perform background jobs via push notifications through the same function used in previous iOS versions:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))handler{ //execute the background job here }

All you have to do is add the content-available flag to the push before sending it and set it equal to 1.

Like so for js:

data: { alert: "Some alert", type: someType, "content-available": 1, id: someId }

Recommend

  • jquery autocomplete, return results to separate layer
  • How to use iOS 10 UserNotifications framework in xcode 7.3.1 swift 2.2?
  • Calculate and compare coefficient estimates from a regression interaction for each group
  • Submitting a Form using Selenium in Python
  • numerous similar AJAX suggestion boxes without ID's
  • Repeat interval for UNNotification
  • Do lifetime parameters in `*(&'a mut self)` methods confuse the BorrowChecker?
  • Title cutoff in tabbed page in Xamarin.Forms
  • Trouble downloading file from browser on Android
  • Reload UITableView from another tab
  • Why doesn't a local variable live long enough for thread::scoped?
  • Is there any way to call saveCurrentTurnWithMatchData without sending a push notification?
  • Angular Bootstrap Carousel Slide Transition not working correctly
  • jquery validation - waiting for remote check to complete
  • What command do i need to pass in SabreCommandLLSRQ to get current price of PNR?
  • PushKit for VOIP iOS apps
  • Android cannot disable cut copy paste
  • JSR-330 support in Picocontainer : @Inject … @Named(\"xxx)
  • Eclipse MTJ doesn't see Java ME SDK 3.0 devices
  • what makes a request a new request in asp.net C#
  • Creating a DropDownList
  • blade.php method outputting it's result to the form
  • Who propagate bugfixes across branches (corporate development)?
  • Why cepheus don't send int without quotes to orion?
  • how does System.Web.HttpRequest::PathInfo work?
  • Scala multiline string placeholder
  • Does Mobilefirst provide a provision to access web services directly?
  • Silverlight DependencyProperty.SetCurrentValue Equivalent
  • Spring Cloud Microservice Architecture Confusion
  • Transactional Create with Validation in ServiceStack Redis Client
  • Handling un-mapped Rest path
  • Scrapy recursive link crawler
  • Exchange data b/w iOS devices using Bluetooth 4.0
  • PHP - How to update data to MySQL when click a radio button
  • Sony Xperia Z Tablet not found by adb
  • Can I make an Android app that runs a web view in Chrome 39?
  • Do create extension work in single-user mode in postgres?
  • R: gsub and capture
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • Comma separated Values
  • How to push additional view controllers onto NavigationController but keep the TabBar?
  • How to load view controller without button in storyboard?