Technical Q&A QA1329

In-App Purchase Product Identifiers

Q:  I am implementing In-App Purchase and must register my product identifiers. What are product identifiers and how do I create and use them in my application?

A: A product identifier is a string used to uniquely identify every product you wish to sell from your application. The App Store uses it to retrieve information about a product. It is a string identifier that can only contain alphanumeric (A-Z,a-z,0-9), underscore (_), and period (.) characters. You can use any sequence of these characters for your identifier. However, we recommend that you use the reverse domain name style (for example, com.companyname.application.productid) when creating your identifier.

How do I create a product identifier?

The In-App Purchases form is used to generate In-App Purchase products. It contains a Product ID field that must be filled. Use this field to specify the product identifier for your product. Follow the steps below to create a product identifier:

Figure 1 displays the com.apples.mygreatapp.consumable1 and com.apples.mygreatapp.sport7days product identifiers for the My Great App application.

Figure 1  In App Purchase items

How do I use a product identifier in my application?

You create an SKProductsRequest object, then pass your list of product identifiers to its initWithProductIdentifiers method to retrieve information about your products. See Listing 1 for an example that requests information about the products associated with the product identifiers shown in Figure 1.

Listing 1  Retrieve information about products

- (void) requestProductData
{
  //Create a list of product identifiers
  NSSet *productSet =[NSSet setWithObjects: @"com.apples.mygreatapp.consumable1",
                                            @"com.apples.mygreatapp.sport7days",nil];
 
  //Create and initialize a products request object with the above list
  SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers: productSet];
 
  //Attach the request to your delegate
  request.delegate = self;
 
  //Send the request to the App Store
  [request start];
}


Document Revision History


DateNotes
2012-01-25

Updated the "How do I create a product identifier?" section.

2011-07-18

Updated screenshot.

2010-01-18

New document that describes how to create and use product identifiers for In-App Purchase.