Short version: in my app background fetch works like a charm except that when I try to load contents in a webview it does nothing at all!
Long version: I set the right capabilities in the project, set the fetch interval and implement the
- (void) application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
method as in the examples and it works. But then, to complete my background fetch I need to load some contents in a UIWebView. And this doesn't work. Simply the process somehow "get lost" when i call:
[myWebview loadRequest:request];
(of course it works when in foreground, but does nothing when in background).
I also try to force the webview to be loaded in the main thread, but then the system simply halt it 'till the app return in foreground mode (it make sense, we are in background!)
So, there's a way to load a UIWebView while in background? Please note I can't simply download the contents with NSURLSession, 'cause the webpage contains javascript that load some of the frames (and I can't ask for a redesign of the webpage).
Edit: probably I wasn't crear enough when I wrote the question, but trying to execute a task it in the main_queue (with a dispatch_async o likewise methods) while in a background fetch does not work. I tried it before asking...