I need to make small downloads started when my application is in the background and wakes up due to significant changes in location. BUT NSURLSessionConfiguration apple documentation here:
https://developer.apple.com/library/IOs/documentation/Foundation/Reference/NSURLSessionConfiguration_class/index.html#//apple_ref/occ/instp/NSURLSessionConfiguration/discretionary
says the following for a discretionary property:
When transferring large amounts of data, it is recommended that you set the value of this property to YES. This allows the system to schedule these from time to time and ensures more optimal operation of the device. For example, the system may delay the transfer of large files until the device is connected and connected to the network via Wi-Fi. The default value of this property is not.
The session object applies the value of this property only to pass your application when it is in the foreground. The transfer started when your application is in the background, the system always starts the transfer at its discretion - in other words, the system assumes that this property is YES and ignores any value you specify.
This seems to imply that if booting starts in the background, the OS always has the right to whether and when to continue booting. It seems that the OS is always waiting for a Wi-Fi connection until these tasks are completed. My experience confirms this hypothesis. I found that I can send several notifications for download while the device is on the cellular network. They remain stuck. When I switch the device to Wi-Fi, they all go through.
WTF? Why does Apple forbid to configure this behavior, especially since they have the necessary properties of the NSURLSessionConfiguration object (discretionary, allows CellularAccess). Of course, the user is not always in WiFi mode when boot tasks start. I need to do this in response to waking up the application through significant changes in location. I plan on downloading tasks in a background session and never receive delegate callbacks on a cellular network until I switch to WiFi. So this means that I canβt finish these tasks, since WiFi is available again or will I bring the application back to the forefront?
Do any of you workaround for this?
I already thought about the following:
Starting a multi-year background task (old style) after updating the location and loading my material using the defaultSessionConfiguration function. Is there any experience if this might work? If it is not, I will use NSURLConnection, I think (an even older style).
ios objective-c background nsurlsession nsurlsessiondownloadtask
blackjacx
source share