• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Out of process download support
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Out of process download support


  • Subject: Re: Out of process download support
  • From: Scott Hancher <email@hidden>
  • Date: Fri, 21 Feb 2014 16:21:53 -0800

I am observing documented behavior with the UIApplicationDelegate method application:handleEventsForBackgroundURLSession:completionHandler:. It's called when my application is re-launched in response to completing a download.

However, I never seem to be getting a call to NSURLSessionDelegate's URLSessionDidFinishEventsForBackgroundURLSession:, whether the app is relaunched by the system when the download completes or I relaunch the app prior to the download concluding. I am getting all the callbacks I had been getting already including notification that the download has finished, NSURLSessionDownloadDelegate's URLSession:downloadTask:didFinishDownloadingToURL:.

The documentation states that the completionHandler sent to application:handleEventsForBackgroundURLSession:completionHandler: can be safely invoked when URLSessionDidFinishEventsForBackgroundURLSession: is received. Because of this, I've opted to call the completionHandler on receiving NSURLSessionTaskDelegate's URLSession:task:didCompleteWithError: if it hasn't already been called from URLSessionDidFinishEventsForBackgroundURLSession:

Does this sound reasonable? Should I just not bother calling the completionHandler at all if I never receive a call to NSURLSessionDelegate's URLSessionDidFinishEventsForBackgroundURLSession:? Is there a better method to call it from?

Thank you,
Scott.


I'm currently working on support for this, but I can't seem to figure out how to test it.

It seems to work fine with my application in the background, and although I can't seem to automate a test for this, I can acceptance test it.

However, if my app is quit, then I don't seem to get a call to application:handleEventsForBackgroundURLSession:completionHandler: within a relaunched instance of my app nor is the file I've requested to download actually downloaded. I'm quitting my app via exit(EXIT_SUCCESS), which I suspect isn't ideal, but there doesn't seem to be another mechanism for killing it. I have tried to manually swipe the application up to remove it from the list of running apps on double tapping home, but this doesn't work either.

Do you have any suggestions on how I might be able to test this?

Some snippets of my code:

NSURL *url = "">NSURLRequest *request =
  [NSURLRequest requestWithURL:url
                                     cachePolicy:NSURLRequestReloadIgnoringCacheData
                                 timeoutInterval:60];
NSString *identifier =
  [NSString stringWithFormat:@"SessionId_%@", [[NSUUID UUID] UUIDString]];
NSURLSessionConfiguration *config =
  [NSURLSessionConfiguration backgroundSessionConfiguration:identifier];
NSURLSession *session =
  [NSURLSession sessionWithConfiguration:config
                                                        delegate:self
                                             delegateQueue:[NSOperationQueue mainQueue]];
NSURLSessionTask *sessionTask = [session downloadTaskWithRequest:request];
[sessionTask resume];

Thank you,
Scott.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Out of process download support
      • From: "Quinn \"The Eskimo!\"" <email@hidden>
References: 
 >Out of process download support (From: Scott Hancher <email@hidden>)
 >Re: Out of process download support (From: Fritz Anderson <email@hidden>)
 >Re: Out of process download support (From: Scott Hancher <email@hidden>)

  • Prev by Date: Re: Out of process download support
  • Next by Date: Re: Out of process download support
  • Previous by thread: Re: Out of process download support
  • Next by thread: Re: Out of process download support
  • Index(es):
    • Date
    • Thread