In-App Purchase--Retrieving Product Information(3)

Retrieving(检索) Product Information

When your application is ready to display a store to the user, it must populate(填充、移民) its user interface with information from the App Store. This chapter details how to request product details from the App Store.

Sending Requests to the App Store

Store Kit provides a common mechanism to request information from the App Store. Your application creates and initializes a request object, attaches a delegate to it, and starts the request. Starting a request transmits(发送) it to the App Store, where it is processed. When the App Store processes the request, the request’s delegate is called asynchronously(异步) to deliver the results to your application. Figure 2-1 shows the request model.

Figure 2-1  Store Kit request model

 

In-App Purchase--Retrieving Product Information(3)

If your application quits while a request is pending(挂起), your application needs to resend it.

SKRequest

SKRequest is an abstract base class for requests sent to the store.

SKRequestDelegate

SKRequestDelegate is a protocol that your application implements to handle requests that completed successfully and requests that failed because of an error.

Requesting Information About Products

Your application uses a products request to retrieve localized information about a product. Your application creates a request that contains a list of product identifier strings. As described earlier, your application might embed product identifiers inside your application or it might retrieve the identifiers from an external server.

When you start the products request, the product identifier strings are transmitted to the App Store. The App Store responds with the localized information you previously entered in iTunes Connect. You use these details to populate the user interface of your store. Figure 2-2 shows a products request.

Figure 2-2  A request for localized product information

 

Important You must make a product request for a particular product identifier before allowing the user to purchase that product. Retrieving product information from the App Store ensures that you are using a valid product identifier for a product you have marked available for sale in iTunes Connect.

 

SKProductsRequest

An SKProductsRequest object is created with a list of product identifier strings for the products you want to display in your store.

SKProductsRequestDelegate

The SKProductsRequestDelegate protocol is implemented by an object in your application to receive the response from the store. It receives the response asynchronously when the request is successfully processed.

SKProductsResponse

An SKProductsResponse object contains a SKProduct object for each valid product identifier in the original request as well as a list of the product identifiers that were not recognized by the store. The store might not recognize the identifier for a number of reasons; it might be misspelled, marked unavailable for sale, or changes you have made in iTunes Connect have not propagated to all of the App Store servers.

SKProduct

An SKProduct object provides localized information about a product you’ve registered with the App Store.

 

THE END !

你可能感兴趣的:(format)