Discretionary Background NSURLSession behavior when there is no internet
| Originator: | jasongregori | ||
| Number: | rdar://14825083 | Date Originated: | 23-Aug-2013 04:56 PM |
| Status: | Open | Resolved: | |
| Product: | iPhone SDK | Product Version: | 7.0 |
| Classification: | Enhancement | Reproducible: | Always |
Summary: I want discretionary background NSURLSessions to intelligently wait to send uploads until there is internet (if there isn't any right now). Does it? Steps to Reproduce: 1. Turn on airplane mode 2. Send upload with NSURLSession 3. Quit App and force it to stop running completely 4. Turn off airplane mode 5. Wait 10 minutes Expected Results: I expected the upload to send when the internet came back on. Actual Results: The connections didn't send after about 10 minutes. I reopened the app and I got "The operation couldn't be completed" errors (code -999). Regression: Maybe it would have sent them in a little while but just canceled because it hadn't sent them by the time I re-registered? If thats the case, please let me know and let me know how long it could potentially be until it is sent. Notes: Here is my use case: I work on an SDK that reports analytic information back to our servers. The data must be sent in a timely fashion so what would be optimal for me is if NSURLSession could send the data right away but if there is no internet, wait until there is internet, send the info, then notify me the next time the app is running so I can clean up the files. If this is what discretionary does, then that would be perfect for me as long as it sends its data relatively quickly after it gets internet. What are the rules for when it sends data? Could it wait a day even if there is cellular internet because it is waiting for wifi or to be plugged in? If not, could you recommend how I should be using NSURLSession with this use case? Another idea I had was to use Reachability, a non discretionary session, and a discretionary session. If there is internet, use the non discretionary one, if there isn't, use the discretionary one. Thank you, Jason
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!