iOS Developer Library — Prerelease

Developer

StoreKit Framework Reference SKStoreProductViewController Class Reference

Options
Deployment Target:

On This Page
Language:

SKStoreProductViewController

A SKStoreProductViewController object presents a store that allows the user to purchase other media from the App Store. For example, your app might display the store to allow the user to purchase another app.

To display a store, create a new SKStoreProductViewController object and set its delegate. Then, present the view controller modally from another view controller in your app. Your delegate dismisses the view controller when the user completes the purchase.

To choose a specific product, call the loadProductWithParameters:completionBlock: method, passing the iTunes item identifier for the item you want to sell.

  • Loads a new product screen to display.

    Declaration

    Swift

    func loadProductWithParameters(_ parameters: [String : AnyObject], completionBlock block: ((Bool, NSError?) -> Void)?)

    Objective-C

    - (void)loadProductWithParameters:(NSDictionary<NSString *,id> * _Nonnull)parameters completionBlock:(void (^ _Nullable)(BOOL result, NSError * _Nullable error))block

    Parameters

    parameters

    A dictionary describing the content you want the view controller to display. See Product Dictionary Keys.

    block

    A block to be called when the product information has been loaded from the App Store. The completion block is called on the main thread and receives the following parameters:

    result

    YEStrue if the product information was successfully loaded, otherwise NOfalse.

    error

    If an error occurred, this object describes the error. If the product information was successfully loaded, this value is nil.

    Discussion

    In most cases, you should load the product information and then present the view controller. However, if you load new product information while the view controller is presented, the contents of the view controller are replaced after the new product data is loaded.

    Availability

    Available in iOS 6.0 and later.

  • Keys supported in the product dictionary.

    Declaration

    Swift

    let SKStoreProductParameterITunesItemIdentifier: String let SKStoreProductParameterAffiliateToken: String let SKStoreProductParameterCampaignToken: String let SKStoreProductParameterProviderToken: String

    Objective-C

    NSString * const SKStoreProductParameterITunesItemIdentifier; NSString * const SKStoreProductParameterAffiliateToken; NSString * const SKStoreProductParameterCampaignToken; NSString * const SKStoreProductParameterProviderToken;

    Constants

    • SKStoreProductParameterITunesItemIdentifier

      SKStoreProductParameterITunesItemIdentifier

      The value of this identifier is an instance of NSNumber, representing the iTunes identifier for the item you want the store to display when the view controller is presented.

      To find a product’s iTunes identifier, go to linkmaker.itunes.apple.com and search for the product, then locate the iTunes identifier in the link URL. For example, the iTunes identifier for the iBooks app is 364709193.

      Available in iOS 6.0 and later.

    • SKStoreProductParameterAffiliateToken

      SKStoreProductParameterAffiliateToken

      The value of this token is an instance of NSString, representing the affiliate identifier you wish to use for any purchase made through the view controller.

      You receive an affiliate identifier when you sign up for the Affiliate Program. The affiliate associated with this view controller is paid a commission for any items purchased using the controller.

      Learn more about the Affiliate Program at https://apple.com/itunes/affiliates.

      Available in iOS 8.0 and later.

    • SKStoreProductParameterCampaignToken

      SKStoreProductParameterCampaignToken

      The value of this token is an instance of NSString, representing an App Analytics campaign. This value can contain any 40-byte string.

      This token allows you to track the effectiveness of your Affiliate Program link and your App Analytics campaign. For more information about the Affiliate Program, see the Affiliate Program at https://apple.com/itunes/affiliates. For more information about iTunes Connect Analytics, see Viewing App Analytics in iTunes Connect Developer Guide.

      Available in iOS 8.0 and later.

    • SKStoreProductParameterProviderToken

      SKStoreProductParameterProviderToken

      The value of this token is an instance of NSString, containing the provider token for the developer that created the app specified by the SKStoreProductParameterITunesItemIdentifier key.

      Use your own provider token when cross promoting your own apps. This token lets you track the effectiveness of the cross promotion effort separate from any affiliate campaign that shares the same campaign token.

      When promoting apps for other developers, use their provider token instead. In this case, the token lets the developer track the effectiveness of your App Analytics campaign for their apps.

      The key must be used in combination with your SKStoreProductParameterCampaignToken. For more information, see Viewing App Analytics in iTunes Connect Developer Guide.

      Available in iOS 8.3 and later.