Issue in accessing internet when app is launched from BGAppRefreshTask |BGProcessingTask

Use case : We want to update our app content while the app is in the background. We want to download some json data from our backend server(HTTP GET) and update the content of the application so that next time when user launches the app he see updated content. We are using apple’s BackgroundTasks framework API, specially BGAppRefreshTask and BGProcessingTask. Pretty standard

Problem → HTTP request via URLSession does not work.

We register and schedule BGAppRefreshTask and BGProcessingTask. Our application is launched in the background by iOS. But when we make an HTTP request to a web server, we do not get any response callback. With default configuration, after making the request the response callback or the URLSessionDataDelegate methods are not called at all. (I also tried with google url. just to be sure the problem is not only with our backend) . Every thing works fine when I check entire flow while debugging and I am connected to Xcode and trigger a background launch by using this command e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"com.background_cloud_sync_apprefresh"] I am kind of stuck with this issue and have run out of ideas to try. So I am reaching out to expert here if you have faced any such issue on iOS.

I have tried URLSession with callback as well as with URLSessionDataDelegate.

In the background processing task case, did you set requiresNetworkConnectivity?

In either case, are you using a standard URLSession or a background session?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Issue in accessing internet when app is launched from BGAppRefreshTask |BGProcessingTask
 
 
Q