Configuring and Creating App Store Hosted Content for iOS 6 In-App Purchases

From Techotopia
Jump to: navigation, search
PreviousTable of Contents
An iPhone iOS 6 In-App Purchase Tutorial


Purchase the fully updated iOS 10 / Swift 3 / Xcode 8 edition of this book in eBook ($19.99) or Print ($45.99) format.
iOS 10 App Development Essentials Print and eBook (ePub/PDF/Kindle) edition contains over 100 chapters. Learn more...

Buy eBook Buy Print Preview Book


As discussed in Building In-App Purchasing into iPhone iOS 6 Applications, iOS 6 provides the option to host the content associated with a server based in-app purchase on Apple’s own App Store servers. This service is provided by Apple to application developers at no additional cost. Prior to iOS 6, it was the responsibility of the developer to set up and configure a server based system for server based in-app purchases.

The steps involved in implementing hosted content downloads from within application code were covered in the Building In-App Purchasing into iPhone iOS 6 Applications chapter. One area that has yet to be covered in detail, and the main focus of this chapter, involves the mechanism for creating the hosted content package and uploading it to the App Store server.




Configuring an Application for In-App Purchase Hosted Content

Before a hosted content package is created and uploaded, the corresponding application and in-app purchase product item must be configured in iTunes Connect. Assuming that the application is registered, select the application under the Manage Your Applications link and, within the App Information screen, click on the Manage In-App Purchases button.

Click on the Create New button on the In-App Purchases screen and select the type of purchase to be configured (for hosted content this is most likely to be non-consumable). Enter a reference name for the product (this will be used to list the product in iTunes Connect and within sales reports) and the product ID that will be used when referencing this product in the application code. Mark the product as cleared for sale, set a pricing tier and then specify a product title and description for at least one language.

Finally, set the Hosting Content with Apple option to Yes before saving the new product to the App Store. Once saved, the purchase will be listed by iTunes Connect as “Waiting for Upload”.


App Store Hosted In App Purchase Item Ready for Upload

Figure 78-1


The Anatomy of an In-App Purchase Hosted Content Package

An in-app purchase hosted content package consists of a structured folder, the root level of which must contain a ContentInfo.plist file which, in turn, contains two keys:

  • ContentVersion – The version number of the content.
  • IAPProductIdentifier – The product identifier of the product with which the content is associated

The folder must also contain a sub-folder named Contents in which resides the content files associated with the in-app purchase. App Store hosted content packages are limited to 2GB in size and must not contain executable code or content that violates any of Apple’s guidelines.


Creating an In-App Purchase Hosted Content Package

The easiest way to create a hosted content package is to use Xcode. To do so, launch Xcode and create a new project. When prompted to select a template for the new project, select the Other entry listed under iOS in the left hand panel of the template screen and, in the main panel, select In-App Purchase Content as demonstrated in Figure 78-2:


Creating an In-App Purchase package using Xcode

Figure 78-2


Click Next, and on the subsequent screen enter a name for the content package which matches the product ID of the purchase item as declared in iTunes Connect. Click Next and choose a location for the project before clicking on the Create button

Within the main Xcode screen, unfold the Supporting Files section of the project navigator panel and select the ContentInfo.plist file. Review the contents of the file and note that the version is set to 1.0 by default. Since this is the first version of the content this can be left unchanged. If the content is modified at any point in the future this version number should be incremented accordingly.

Using a Finder window, locate the content files that are to be hosted on the App Store and drag and drop them onto the Supporting Files header in the Xcode project navigator panel and click Finish on the resulting panel.

Archiving the Hosted Content Package

With the content configured, the next step is to create the hosted content package file. This is achieved by selecting the Xcode Product -> Archive menu option. Once the package has been created, display the Organizer window and select the Archives tab as shown in Figure 78-3:


In-App Purchase Package Archive

Figure 78-3


Validating the Hosted Content Package

Before the package is uploaded to Apple’s servers, it should first be validated to ensure it does not contain ineligible content. To perform the verification, click on the Validate… button in the Organizer window and enter your Apple developer program credentials to verify that the content meets Apple’s format guidelines. Xcode will then ask that the application and in-app purchase product for which the content is to be associated be selected from two drop down menus as illustrated in Figure 78-4.


Validating In App Purchase Hosted Content Package

Figure 78-4


With the correct Application and In-App Purchase Content items selected, click Next to initiate the validation process. If the validation succeeds, the package is ready for upload. In the event that the validation fails, read the error description and make corrections to the content files accordingly.

Uploading the Hosted Content Package

Assuming validation was successful, click on the Distribute… button in the Organizer window and select the option to Submit in-app purchase content. Once again, enter your developer program credentials and select both the application and product ID to complete the upload process.

As an alternative to submitting the content within Xcode, select the option to Export Package, and then use the Application Loader tool to upload it to iTunes Connect.

Once the upload is complete, the hosted content package will be listed in iTunes Connect (Figure 78-5).


In-App Purchase App Store hosted content uploaded to iTunes Connect

Figure 78-5


The content is now available for download as part of an in-app purchase using the steps outlined in Building In-App Purchasing into iPhone iOS 6 Applications.

Summary

In-app purchases can potentially include additional content that needs to be downloaded to the user’s device as part of the purchase process. Prior to the introduction of iOS 6, the hosting of this content on a remote server was the responsibility of the application developer, including the associated security infrastructure to validate purchases prior to download.

iOS 6, however, introduced the ability to upload content packages for hosting on Apple’s App Store servers. The steps to initiate in-app purchase downloads from the App Store were covered in the chapter entitled Building In-App Purchasing into iPhone iOS 6 Applications. This chapter has walked through the steps involved in creating an App Store in-app hosted package and uploading it to the App Store.


Purchase the fully updated iOS 10 / Swift 3 / Xcode 8 edition of this book in eBook ($19.99) or Print ($45.99) format.
iOS 10 App Development Essentials Print and eBook (ePub/PDF/Kindle) edition contains over 100 chapters. Learn more...

Buy eBook Buy Print Preview Book



PreviousTable of Contents
An iPhone iOS 6 In-App Purchase Tutorial