In-App Purchases (IAP) in iOS using StoreKit

Offering in-app purchases is one of the main ways through which apps can make money in the App Store. Since the introduction of in-app purchases, they’ve been handled through the StoreKit framework.

This article will help you learn how you can easily implement in-app purchases and subscriptions, and discover APIs for retrieving product information, handling transactions, determining product entitlements and customer status, as well as comprehensive testing support in Xcode.

Types

In-app purchases don’t come in one unique form. With this in mind, to get the most out of them, you need to create your custom in-app purchase strategy. You can create up to 10,000 in-app purchase products per app. There are four in-app purchase types:

  1. Consumable -> A product that is used once, after which it becomes depleted and must be purchased again. Example: fish food in a fishing app.
  2. Non-Consumable -> A product that is purchased once and does not expire or decrease with use. Example: Race track for a game app.
  3. Auto-Renewable Subscription -> A product that allows users to purchase dynamic content for a set period. This type of Subscription renews automatically unless cancelled by the user. Example: Monthly subscriptions for an app offering streaming services.
  4. Non-Renewing Subscription -> A product that allows users to purchase a service with a limited duration. The content of this in-app purchase can be static. This type of Subscription does not renew automatically. Example: One year subscription to a catalog of archived articles.

You can sync and restore non-consumables and auto-renewable subscriptions across devices using StoreKit. When a user purchases an auto-renewable or non-renewing subscription, your app is responsible for making it available across all the user’s devices, and for enabling users to restore past purchases.

Workflow

  1. Sign the Paid Applications Agreement
  2. Configure in-app purchases in App Store Connect
  3. Enable in-app purchase in Xcode
  4. Design and create your in-app purchase
  5. Test in-app purchases
  6. Publish on the App Store

StoreKit 1 vs StoreKit 2

StoreKit has been with us since iPhone OS 3.0 launched in 2009. At WWDC 2021, we saw the introduction of the new StoreKit 2 — a new Swift-only framework with modern async APIs.

Using StoreKit 2 is not possible with Objective-C or if you need to support versions before iOS 15.0. So, migrating to StoreKit 2 might not be as straightforward for all apps with existing StoreKit 1 implementations.

StoreKit 2 does not provide a replacement for every single API that StoreKit 1 has. It’s clear that Apple’s focus is now on StoreKit 2 moving forward: iOS 16 only brought improvements to StoreKit 2.