Add In-App Purchase Capability Using Xcode

In this chapter, you’ll add two types of in-app purchases to the gloopdrop project: one to remove banner ads, and one to let the player purchase additional opportunities to continue the game.

To enable in-app purchases in Gloop Drop, you need to add the In-App Purchase capability to the Xcode project and target.

Open the gloopdrop project in Xcode.

In the Project Navigator, select the gloopdrop project file, and in the Project Editor, select the gloopdrop target. Now, switch to the Signing & Capabilities tab and you’ll see something like this:

images/MonetizingYourGamesWithInAppPurchases/iap-pre-add-capability.png

As you learned in Chapter 1, Creating Scenes with Sprites and Nodes, the Bundle Identifier must be unique when publishing a project to the App Store. Because the Bundle ID, net.justwritecode.gloopdrop, already exists on my Apple developer account, be sure to change the Bundle ID to something else (if you haven’t done so already)—preferably a domain that you own.

With the Bundle ID set to something unique, the next step is to add the In-App Purchase capability.

Before you begin, verify that you have the Automatically manage signing option enabled. When that option is enabled, Xcode will handle setting up the profiles, app IDs, and certificates you’ll need to successfully publish to the App Store.

To add a new capability, click the + Capability button in the top-left corner of the Project Editor window. You’ll see something like the image.

images/MonetizingYourGamesWithInAppPurchases/iap-add-capability.png

Here, you can select the capability you wish to add. Scroll down to the In-App Purchase capability and double-click the row to add that capability. Because the Automatically manage signing option is enabled, Xcode creates the necessary profiles, apps IDs, and certificates needed to work with and support in-app purchases.

If everything went as expected, you’ll see the In-App Purchase capability listed at the bottom of the Signing & Capabilities tab.

Your next task is to set up the app in App Store Connect.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.155.88