Class

SKDownload

A SKDownload object represents downloadable content associated with a product. When you create a product in iTunes Connect, you can associate one or more pieces of downloadable content with it. Then, at runtime, when a product is purchased by a user, your app uses SKDownload objects to download the content from the App Store.

Overview

Your app never directly creates a SKDownload object. Instead, after a payment is processed, your app reads the transaction object’s downloads property to retrieve an array of SKDownload objects associated with the transaction. Then, to download the content, you queue a download object on the payment queue and wait for the content to be downloaded. After a download completes, read the download object’s content​URL property to get a URL to the downloaded content. Your app must process the downloaded file before completing the transaction. For example, it might copy the file into a directory whose contents are persistent. Once all downloads are complete, you finish the transaction. After the transaction is finished, the download objects cannot be queued to the payment queue and any URLs to the downloaded content are invalid.

Symbols

Obtaining Information about the Downloadable Content

var content​Identifier:​ String

A string that uniquely identifies the downloadable content.

var content​Length:​ Int64

The length of the downloadable content, in bytes.

var content​Version:​ String

A string that identifies which version of the content is available for download.

var transaction:​ SKPayment​Transaction

The transaction associated with the downloadable file.

Obtaining Information about the State of a Download

var download​State:​ SKDownload​State

The current state of the download object.

var state:​ SKDownload​State

The current state of the download object.

var progress:​ Float

A value that indicates how much of the file has been downloaded.

var time​Remaining:​ Time​Interval

An estimated time, in seconds, to finish downloading the content.

Accessing a Completed Download

var error:​ Error?

The error that prevented the content from being downloaded.

var content​URL:​ URL?

The local location of the downloaded file.

Managing Downloaded Content

class func content​URL(for​Product​ID:​ String)

Returns the local location for the previously downloaded flie.

class func delete​Content(for​Product​ID:​ String)

Deletes the previously downloaded file.

Constants

SKDownload​State

The states that a download operation can be in.

Download Time Values

Time values used to show special download states.

Relationships

Inherits From