0
votes

Everyone,

I have searched a while and it appears I could not get answer to the following question:

-(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))fetchCompletionHandler { .....

NSURLSessionConfiguration * config=[NSURLSessionConfiguration backgroundSessionConfiguration:@"10-MIN-COREDATA-UPDATE" ]; config.timeoutIntervalForRequest=150.0; config.timeoutIntervalForResource=2500.0;

 NSURLSession *  session=[NSURLSession  sessionWithConfiguration:config delegate:nil delegateQueue:  nil ];  
NSURLSessionDownloadTask *bgDownloadTask=[session downloadTaskWithURL:MyURL completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) {
    // use the downloaded file to update  a coredata  big table
    [self processFileAndUpdateCoreData];  // this may take long time
}] ;

[bgDownloadTask resume];

..... }

I know background Fetch has a wall clock of 30 seconds but I read Background data transfer (NSURLSession) can download very large files and has no time limits in background mode, if I combine both of these "background" modes into one call, how is the 30-second wall clock calculated? Suppose my code finishes under 30 seconds before calling NSURLsession download (which takes long time to download AND Processing), is my background fetch call still under 30-seconds or I have well overused the allocated 30 seconds background call limit? In another way, how do I calculate time here? Should I exclude NSURL session time or should I include it for the total time elapse for background Fetch call?

Any suggestions and advices are greatly appreciated.

}

1

1 Answers

0
votes

I tried MANY times and launched a background NSURL session in app background refresh call, in NSURL session delegate I use the newly downloaded file to update a big core data schema, the app always gets killed in about 90 seconds. So the answer is: 30 seconds wall clock applies no matter what you do.