25.12.2013 Views

In-App Purchase Programming Guide - Apple Developer

In-App Purchase Programming Guide - Apple Developer

In-App Purchase Programming Guide - Apple Developer

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Retrieving Product <strong>In</strong>formation<br />

Getting a List of Product Identifiers<br />

If your app has a fixed list of products, such as an in-app purchase to remove ads or enable functionality, embed<br />

the list in the app bundle. If the list of product identifiers can change without your app needing to be updated,<br />

such as a game that supports additional levels or characters, have your app fetch the list from your server.<br />

There’s no runtime mechanism to fetch a list of all products configured in iTunes Connect for a particular app.<br />

You’re responsible for managing your app’s list of products and providing that information to your app. If you<br />

need to manage a large number of products, consider using the bulk XML upload/download feature in iTunes<br />

Connect.<br />

Embedding Product IDs in the <strong>App</strong> Bundle<br />

<strong>In</strong>clude a property list file in your app bundle containing an array of product identifiers, such as the following:<br />

<br />

<br />

<br />

<br />

com.example.level1<br />

com.example.level2<br />

com.example.rocket_car<br />

<br />

<br />

To get product identifiers from the property list, locate the file in the app bundle and read it.<br />

NSURL *url = [[NSBundle mainBundle] URLForResource:@"product_ids"<br />

withExtension:@"plist"];<br />

NSArray *productIdentifiers = [NSArray arrayWithContentsOfURL:url];<br />

Fetching Product IDs from Your Server<br />

Host a JSON file on your server with the product identifiers. For example:<br />

[<br />

"com.example.level1",<br />

"com.example.level2",<br />

"com.example.rocket_car"<br />

2013-10-22 | Copyright © 2013 <strong>App</strong>le <strong>In</strong>c. All Rights Reserved.<br />

13

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!