0

I need to fetch data from server and (probably) create local notifications for user. When in foreground, I use separate queue. I can do that when I am in background (after Home button clicked) as well, but there is also "background fetch" feature.

Which one should I use? Is it better to simply use queue or background thread and leave it when app goes to background, or should I pause my thread and wait for "background fetch" request?

user996142
  • 2,753
  • 3
  • 29
  • 48
  • 1
    You have to use background fetch. Your app won't be running in the background otherwise under normal circumstances. – rmaddy Oct 17 '15 at 16:14
  • @rmaddy So, I should stop any activity on ``applicationDidEnterBackground`` and wait for ``performFetchWithCompletionHandler``, am I correct? – user996142 Oct 17 '15 at 17:04
  • 1
    You only get 30 seconds once your app enters the background. So yes, do what you just said. – rmaddy Oct 17 '15 at 17:05
  • @rmaddy I just did an experiment: I scheduled nstimer to run every 10 seconds and print to nslog. I sent my app to background using Home button, and my timer still works after several minutes. Why is not it stopped after 30 secs? – user996142 Oct 17 '15 at 17:12
  • Try it on a real device without the debugger. – rmaddy Oct 17 '15 at 17:12
  • Looks like background apps work forever in simulator. http://stackoverflow.com/a/24222949/996142 – user996142 Oct 17 '15 at 17:24

0 Answers0