Sulabh Sulabh - 1 year ago 88
iOS Question

BackGround Downloading speed in iOS

Is there any speed difference in download speed when app is in background.I am using NSURLSession to download a set of files in background.Also can we restrict the downloads of items to one because when i checked the sample,3 files are getting downloaded.Any ideas?

Answer Source

Yes, there may be a speed difference with background transfers. It's difficult to know what that speed difference will be. Once your app is in the background, the NSURLSession background daemon will manage the download to maximise efficiency, depending on several factors, including other data transfers, the network state (Wi-Fi or cellular, say) and the available battery life of the device.

If you watch the WWDC 2013 session 705 video, "What's New In Foundation Networking", you'll find that covered briefly around 33 minutes in, in the "Background Transfers" section. (That's a section well worth watching if you're interested in background transfers. It includes a full worked example of an app that does a background download.)

Foreground transfers are likely to be faster (as by keeping the app in the foreground, you're effectively hinting to iOS that its associated network transfers are more important to you than anything else that might be going on.)

To restrict the number of concurrent transfers, you probably want to look into the HTTPMaximumConnectionsPerHost property of NSURLSessionConfiguration. There's an example of setting that in the Ray Wenderlich NSURLSession tutorial.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download