Ok, so I watched a sample SimpleBackgroundFetch project, and it uses the following in the App Delegate:
[[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:someTimeInSeconds]; //^this code is in didFinishLaunchingWithOptions -(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { //do something + call completionHandler depending on new data / no data / fail }
So basically I assume that I am calling my application server here to get some data.
But then I saw NSURLSession docs , and it had methods like these
– downloadTaskWithURL:
and he said the following:
This API provides a rich set of delegation methods to support authentication and gives your application the ability to execute background loads when your application is down, or in iOS while your application is paused.
What is the difference between the two APIs? And what should I use if I want to download some data from my application server from time to time?
I simply was not sure of the difference between the two, so I just thought that I should find out my doubts. Go StackOverflow!
source share