SKStoreProductViewController Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/StoreKit.framework
Availability
Available in iOS 6.0 and later.
Companion guide
Declared in
SKStoreProductViewController.h

Overview

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.

Tasks

Setting a Delegate

Loading a New Product Screen

Properties

delegate

The store view controller’s delegate.

@property(nonatomic, assign) id<SKStoreProductViewControllerDelegate> delegate
Discussion

Your application must set the delegate before presenting the store view controller.

Availability
  • Available in iOS 6.0 and later.
Declared In
SKStoreProductViewController.h

Instance Methods

loadProductWithParameters:completionBlock:

Loads a new product screen to display.

- (void)loadProductWithParameters:(NSDictionary *)parameters completionBlock:(void (^)(BOOL result, NSError *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

YES if the product information was successfully loaded, otherwise NO.

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.
Declared In
SKStoreProductViewController.h

Constants

Product Dictionary Keys

Keys supported in the product dictionary.

NSString * const SKStoreProductParameterITunesItemIdentifier;
Constants
SKStoreProductParameterITunesItemIdentifier

The value associated with this key 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.

Declared in SKStoreProductViewController.h.