Skip to content
anystone edited this page Mar 21, 2011 · 25 revisions

Installation

The following instructions assume the use of Xcode 4. If you are using Xcode 3, the steps are similar, but different. ;)

  1. In Xcode 4, open the project you wish to add in app purchase functionality to
  2. In the finder, find the location of the "ASTStoreController.xcodeproj"
  3. Drag "ASTStoreController.xcodeproj" into a folder in your open Xcode project navigator view
  4. To simplify access to the public headers, select the "ASTStoreControllerHeaders" folder and drag a copy out of the ASTStoreController.xcodeproj enclosure and into somewhere else in your project
  5. In the "Project Navigator" select the target you wish to include the ASTStoreController in, and select the "Build Phases" tab. Under "Link Binary with Libraries", select the + sign and add libASTStoreController.a

Startup

The ASTStoreController is a singleton class. It is recommended that you initialize it in your AppDelegate so that it can process any outstanding transactions from the App Store as soon as possible.

  1. In your AppDelegate.m add the following in the header import section:
#import "ASTStoreController.h"
  1. In the AppDelegate.m function:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 

Add the following code to initialize the ASTStoreController. This method assumes that lazy access to the app store is desired.

[ASTStoreController sharedStoreController];
  1. You should then initialize the controller with the list of products you wish to manage. For a simple application with a nonconsumable purchase you could use:
[[ASTStoreController sharedStoreController] setNonConsumableProductIdentifier:@"com.example.purchase"];

This function can be called multiple times to add multiple non-consumable product identifiers. For more complex in app purchase setup you are recommended to take advantage of the plist initialization format. For more details see TBD.

Store View Controller

ASTStoreController allows for lazy initialization of the store. Why communicate with store if your customer doesn't enter your in-app store?

In your viewDidLoad or viewWillAppear methods, invoke the ASTStoreController method to start downloading the information from the app store.

[[ASTStoreController sharedStoreController].delegate = self;
[[ASTStoreController sharedStoreController] requestProductDataFromiTunes:NO];

It will then start issuing updates to the delegate via

- (void)astStoreControllerProductDataStateChanged:(ASTStoreControllerProductDataState)state;

Clone this wiki locally