Background NSURLSession without application delegate callback
| Originator: | jasongregori | ||
| Number: | rdar://14182015 | Date Originated: | June 17, 2013 |
| Status: | Closed | Resolved: | Yes |
| Product: | iOS SDK | Product Version: | 7.0 |
| Classification: | Enhancement | Reproducible: |
17-Jun-2013 04:31 PM Jason Gregori: Summary: Is there anyway to use background NSURLSessions without `-application:handleEventsForBackgroundURLSession:completionHandler:` ever getting called on my application delegate? I work on an SDK and we would love to use NSURLSession for sending our SDK data back to our servers (we want the data to be sent in the background without requiring the app to stay running). However, we do not want to interfere with the main application delegate since they won't know what they are seeing and we don't want them to have to worry about it. In addition, we don't really need to know when the request completed right away. It is fine for us to wait until the next time the app runs to get our delegate callbacks. If the app is completely shut down (not suspended), then on startup we can create a new NSURLSession with a matching identifier to the old one and continue to get delegate callbacks there. Preferably, I would just want a property on NSURLSessionConfiguration that disabled app delegate callbacks. It would behave like: Steps to Reproduce: So what I would want is: Create a background NSURLSession as normal. Set special property on NSURLSessionConfiguration. If the app goes into the background or shuts down completely, and there is a delegate call needed... Expected Results: ... app does not get launched into the background. On next start up, when matching NSURLSession is created, delegate calls stream in. Actual Results: ... app gets launched into the background. Developer (user of our sdk) does not handle our NSURLSession correctly or just forgets to handle it. Regression: Notes: Thanks! 25-Jun-2013 04:04 PM Jason Gregori: Note: Without something like this we are forced to continue to use NSURLConnection and background tasks. 29-Jul-2013 11:21 AM Apple Developer Bug Reporting Team : Engineering has requested the following information in order to further investigate this issue: Does this issue also occur with iOS 7 beta 4 (11A4435d)? Please verify with this release, and update your report with the results. 06-Aug-2013 03:05 PM Jason Gregori: Wow this is awesome! Thank you so much! `sessionSendsLaunchEvents` sounds like exactly what I wanted. There isn't any documentation yet, but I assume this works exactly the same it just doesn't launch the app when a connection fails or succeeds? I would just create a new matching session on next start up and get any pending notifications at that time? 19-Aug-2013 06:18 PM Apple Developer Bug Reporting Team : It is yes for both your question.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!