iOS Background downloads when the app is not active

后端 未结 8 1494
日久生厌
日久生厌 2020-11-27 13:28

When my app is initially downloaded, the user needs to download a large file something like 200MB (upper limit). I definitely can\'t expect the user to keep the app open til

8条回答
  •  无人及你
    2020-11-27 13:30

    You could use NSURLSession introduced in iOS 7.0 and later to continue the uploading/download of an file even when the app is suspended.

    Apple documentation

    The NSURLSession class and related classes provide an API for downloading content. This API provides a rich set of delegate methods for supporting authentication and gives your app the ability to perform background downloads when your app is not running or, in iOS, while your app is suspended.

    And

    Background sessions let you perform uploads and downloads of content in the background while your app is not running. You can create a background session configuration by calling the backgroundSessionConfiguration: method on the NSURLSessionConfiguration class.

    A cool tutorial to use NSURLSession at this link.

提交回复
热议问题