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?
See Create an in-app purchase for more information on how to create a product identifier.
Figure 1 displays the com.samplecode.planners.plates.round.7days
, com.samplecode.planners.coins.100
, com.samplecode.planners.tutorial.1
, and com.samplecode.planners.maps.7days
product identifiers for the Planners
app.
How do I use a product identifier in my application?
You create an SKProductsRequest
object, then pass your list of product identifiers to its init(productIdentifiers:) 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 Retrieving product information.
// Keep a strong reference to the product request. |
var productRequest: SKProductsRequest! |
func retrieveProductInformation() { |
let identifiers = Set(["com.samplecode.planners.plates.round.7days", |
"com.samplecode.planners.coins.100", |
"com.samplecode.planners.tutorial.1", |
"com.samplecode.planners.maps.7days"]) |
// Initialize the product request object with the above list. |
productRequest = SKProductsRequest(productIdentifiers: identifiers) |
//Attach the request to your delegate. |
productRequest.delegate = self |
// Send the request to the App Store. |
productRequest.start() |
} |
Additional Resources
Document Revision History
Date | Notes |
---|---|
2018-05-02 | Updated screenshot and broken links. |
2018-05-01 | Updated screenshot and broken links. |
Updated screenshot and broken links. | |
2017-04-28 | Editorial update. |
2015-11-10 | Editorial Update. |
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. |
Copyright © 2018 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2018-05-02