An instance of the NKAsset
class represents an asset that is being downloaded (or has downloaded) for an issue of a Newsstand application.
Deprecated
Use remote notifications to download content silently in the background. For information, see Pushing Background Updates to Your App.
SDK
- iOS 5.0–13.0Deprecated
Framework
- Newsstand
Kit
Declaration
class NKAssetDownload : NSObject
Overview
An asset can be either a component of an issue—for example, an HTML file, a plain-text file, an image, or a video—or the entire issue compressed in a ZIP or other archive. The latter approach is recommended.
You create an NKAsset
instance using the NKIssue
method add
; you pass into this method an NSURLRequest
object that contains the URL locating the asset on the application’s server. To begin downloading the asset, call download(with:)
on the NKAsset
object. The delegate specified as the parameter of this message must adopt the NSURLConnection
protocol. It should implement the three methods specific to handling downloads of issue assets:
connection(_:
— The delegate updates a progress indicator as the download proceeds.did Write Data: total Bytes Written: expected Total Bytes:) connection
— The delegate updates a progress indicator as a stopped download resumes.Did Resume Downloading(_: total Bytes Written: expected Total Bytes:) connection
— The delegate moves or otherwise processes the downloaded asset.Did Finish Downloading(_: destination URL:)
If a Newsstand application terminates while asset downloading is underway, the downloading continues in the background. When the asset is downloaded, the application is brought to the foreground if it has a newsstand-content
value for the UIBackgroundModes array in the information property list. It should obtain an instance of NKIssue
and iterate through the NKAsset
objects in the downloading
array; for each object, call download(with:)
on it and have the delegate process the remaining downloads.
Note
This download resumption procedure is required. If an application does not do this, any unfinished downloads are eventually purged.