Subscriptions 101: learn how to get +23% app revenue Read more

iOS in-app purchases, part 1: Configuration and adding to the project

Vitaly Davydov

July 10, 2020

12 min read

Table of Contents

612ce363e6f8fb814feed86a ios tutorial 1 configuration min

Subscriptions are one of the ways to monetize an app. Developers can get a recurrent income and provide users with up to date content. Unlike regular purchases, where Apple takes a 30% commission, this commission reduces to 15% in case the user is subscribed during one year or longer. Important: if the user cancels the subscription, this counter resets in 60 days.

With this article, we start our series of tutorials on integrating in-app purchases into an app. Here is what we’ll be talking about:

  1. iOS in-app purchases, part 1: configuration and adding to the project.
  2. iOS in-app purchases, part 2: initialization and purchases processing.
  3. iOS in-app purchases, part 3: testing purchases in XCode.
  4. iOS in-app purchases, part 4: server-side receipt validation.
  5. iOS in-app purchases, part 5: the list of SKError codes and how to handle them.

In this part we will learn how to:

  • Create purchases in App Store Connect.
  • Configure subscriptions: set a duration, price, trial periods.
  • Get a list of purchases in-app.

Creating purchases

Before implementing your in-app purchases you have to:

  • Pay for the Apple Developer account as a natural person or an entity.
  • Accept all the agreements in App Store Connect. Updated agreements will appear in your App Store Connect account, it’s easy to notice them.

Let’s assume that our app will have two types of subscriptions: monthly and annual. Each of them will have a 7-day free trial.

​​On the application page in App Store Connect, open In-App Purchases tab → Manage. Here you can see the list of created purchases. Click (+) next to the title to create a new purchase.

60231bfa9cca138849212742 image 1
Purchase creation interface

​​You’ll see an in-app purchase dialog appear. Select Auto-Renewable Subscription.

60231c15313112f061718aed image 2
In-app purchase dialogue in App Store Connect. Choose auto-renewable subscription

On the next step, you will be offered to create a Subscription Group.

A Subscription Group is a set of subscriptions with the essential feature: the user cannot activate two subscriptions at the same time from the same group. Besides, all the introductory offers, such as trial subscriptions, are applied directly to the entire group. Groups serve to separate business logic in the application.

Let’s name the group Premium Access. While adding another subscription, the interface will offer you to add it to the existing group. Later you will be able to manage the groups in the In-App Purchases menu → Subscription Groups.

60231c571e9b283be2b1bc41 image 3
Creating subscription group in App Store Connect

Next, fill out the details:

  • Reference Name is the title of your subscription in App Store Connect, as well as in Sales section and the reports
  • Product ID is a unique product identifier, which is used in the application code

I would recommend choosing a simple Product ID name, which could give you as much information as possible. It’s better to indicate subscription duration to ease further analytics evaluation.

Creating subscription in App Store Connect

Add the second product following the previous instruction.

In the end, the interface of In-App Purchases tab → Manage will look like this:

60231cb9864d1635cf011e96 image 5
This is how two subscriptions in one app look like

Subscription configuration

We added the purchases, but they are not ready yet to be used: status bar indicates Missing Metadata. It means we still haven’t added the information about pricing and subscription duration. We’ll fix it now.

Duration and pricing

Click on the product to configure it.

Create a subscription in App Store Connect
Choose duration and set prices

Here we need to choose a Subscription Duration. In our case, we choose 1 Month or 1 Year. Then go to the Subscription Prices menu.

You can flexibly set prices depending on the country, but we will limit ourselves to automatic prices, in USD. App Store Connect will automatically convert prices into another currency, it’s not clear how it works though. Probably you would want to change the price manually adjusting to your target market.

Create a subscription group in App Store Connect

Free trial

One of the most popular ways to increase subscriptions is a free trial:

A user activates it and uses an application for free. If he doesn’t cancel the subscription, after the trial expires, the user is being charged automatically.

The developers love free trials because they work well. Let’s learn how to enable it.

Click (+) next to the title and choose Create Introductory Offer from the list:

Create a subscription group in App Store Connect

Choose a list of countries.

Create a subscription group in App Store Connect

Choose the offer duration. You can set No End Date if you don’t want to limit yourself.

Create a subscription offer in App Store Connect

On the last step, you need to select an Offer Type.

As you can see in the next screenshot, there are three types:

Pay as you go — a reduced-price use: the user pays a reduced price during the initial period and then becomes a regular subscriber with standard prices.

Pay up front — a prepay use: the user pays a fixed amount of money at once and gets an opportunity to use the app during the determined period, and then also becomes a regular subscriber.

Free — a free trial, after its expiry theuser may become a subscriber.

We choose the third one and set the duration for one week.

Create a subscription offer in App Store Connect

Save settings.

Getting the list of SKProduct

Let’s check if the mobile app sees the purchases and then lay the groundwork for further realization of purchases.

It’s a good rule to create a class singleton for working with StoreKit. Such a class has only one instance in the entire app. A lot of productIdentifiers will store our purchases identifiers:

import StoreKit

class Purchases: NSObject {
   static let default = Purchases()

   private let productIdentifiers = Set(
       arrayLiteral: “barcode_month_subscription”, “barcode_year_subscription”

   private var productRequest: SKProductsRequest?

   func initialize() {

   private func requestProducts() {
       // Will implement later

Only identifiers are not enough.

To fully use the purchases you need to get: price, currency, localization, discounts.

SKProduct class returns all this information and even more. To get this information, we need to request Apple. Create an object SKProductsRequest, assign “delegate” (there you will receive the result). Call the method start(), which initialize an asynchronous procedure:

private func requestProducts() {

       let productRequest = SKProductsRequest(productIdentifiers: productIdentifiers)
       productRequest.delegate = self

       self.productRequest = productRequest

If the operation is successful, productsRequest(didReceive response:) method will be called​, which will contain all the relevant information:

extension Purchases: SKProductsRequestDelegate {
    func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {
        guard !response.products.isEmpty else {
            print("Found 0 products")

        for product in response.products {
            print("Found product: \(product.productIdentifier)")

    func request(_ request: SKRequest, didFailWithError error: Error) {
        print("Failed to load products with error:\n \(error)")

If everything is successful, there will be two lines in the log:

Found product: barcode_month_subscription
Found product: barcode_year_subscription

However, if there is an error, then SKProduct with such an ID will not be returned. It may happen if the product has become invalid due to any reason.

That’s it.

The next article will be focused on how to make in-app purchases: open/close transactions, handle errors, validate receipt, and more.

If you liked it, give us on GitHub

Further reading