I think this might be answered quiet a few time, but still there are some unknown cases that I wanted to clarify.
I have been looking at Background Fetch API for one of my iOS application. I learned from several articles that fetchNewDataWithCompletionHandler
will get called when OS decides to check if there is any new data from backend server(irrespective of what custom fetch interval we set). And the articles and tutorials says it will get called only if your application is in inactive/background/suspended state, not when user forcefully terminate the app from app switcher.
But my questions are;
There are two very important scenario to test, first scenario is when your app launched in background to fetch new content, and second one is your app resumed in background to fetch new content.
I think the second scenario is app resumed from background/suspended state. But what is this first scenario? From which state our app will "launch" in background to fetch data? From not running state?
Any thoughts?
Thanks!!
The first case is when your app is not running at the time. iOS has decided that it is going to give your app some time to run, but your app hasn't been launched yet.
This can happen if the phone was recently rebooted (and so your app has never been launched) or most likely if your app was killed because the memory was needed for something else. If the user launches lots of other large apps (e.g. games) then your app will eventually be evicted from memory.
This will never happen if the user killed the app using app switcher; if the user killed the app, then iOS will not restart it because it is assumed that the user wants it to stay dead.