Does someone in this world have a working code with background fetch?

3 weeks in a row I can not get the background fetch to work on my testing iPhone (iOS10)


I tried everything and already despaired. My application has lost functionality. And I can not fix it.

This works when testing in hcode. Then it works several times the first day. And from the next day - silence! All I need is to check the data on the network every three hours and issue a warning when checking.


In iOS 7 it worked perfectly! As soon as I change the test iPhone for iOS10 - it stopped working at all! I tried everything I found on the Internet - but nothing works for more than one day !!!



Why does Apple do this? Why should programmers spend weeks and seek a solution to a problem that was not there before? Can someone answer?

Replies

All I need is to check the data on the network every three hours and issue a warning when checking.

This isn’t really the intended use case for background fetch. The idea behind background fetch is that the system learns when the user is using the app and, if the user is regularly using it at specific times, the system sends the app a background fetch event before that time so that it can refresh. For example:

  • The user might run a social media app regularly throughout the day, so the system would send that app regular background fetch events.

  • The user might run their news app at breakfast time, so the system would send that app a background fetch event early in the morning.

  • The user might have a second news app on their device but never run it, in which case that app would never get any background fetch events.

Background fetch does not guarantee regular background fetch events. Indeed, there is no mechanism on iOS that guarantees regular execution in the background.

Once your app has checked the data on the network, what does it do with that data? It sounds like this might be a perfect candidate for push notifications, that is, you offload the ‘poll the network’ work to your server and which then sends a push notification if something relevant crops up. That notification can either address the user or the app (a so-called silent push), although be aware that silent pushes have their own set of budgetary constraints.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"


WWDC runs Mon, 4 Jun through to Fri, 8 Jun. During that time all of DTS will be at the conference, helping folks out face-to-face.