Build With RevenueCat

Build a customized mobile subscription business with RevenueCat. We do the heavy lifting of normalizing subscribers from any source and maintain a single source of truth for subscription status, so you can get back to building your app.

RevenueCat is a powerful, secure, reliable, and free to use in-app purchase server with global support. All you need to get started is an API key.

Get Started    API Reference

iOS Subscription Offers

Implementing iOS Subscription Offers with Purchases SDK

👍

This guide assumes you already have your iOS products set up in App Store Connect.

In iOS 12.2, Apple announced a new feature for subscription developers called “Subscription Offers.” Subscription offers allow developers to apply custom pricing and trials to existing and lapsed subscriptions.

Subscription Offers are supported in the Purchases SDK, but require some additional setup first in App Store Connect and the RevenueCat dashboard.

1. Configure offer in App Store Connect

Subscription Offers are created from within App Store Connect and are included as a pricing option to an existing subscription product. When you click the "+" option next to Subscription Prices, you'll see an option to Create Promotional Offer.

Subscription Offers are created as new pricing options in App Store Connect

To create the offer there are two fields that you need to specify: Reference Name, which is just used for your reference, and the Promotional Offer Product Code, which is what you will actually use to activate a specific offer in your app.

On the next screen you'll select the type of offer you wish to provide. Just like introductory offers, there are three types of subscription offers:

  1. Pay-up-front — The customer pays once for a period of time, e.g. $0.99 for 3 months. Allowed durations are 1, 2, 3, 6 and 12 months.
  2. Pay-as-you-go — The customer pays a reduced rate, each period, for a number of periods, e.g. $0.99 per month for 3 months. Allowed durations are 1-12 months. Can only be specified in months.
  3. Free — This is analogous to a free trial, the user receives 1 of a specified period free. The allowed durations are 3 days, 1 week, 2 weeks, 1 month, 2 months, 3 months, 6 months, and 1 year.

📘

Don't forget to click Save in the upper right after you configure the offer.

Subscription Keys

After you've created an offer, you need to make sure you have a subscription key to securely authenticate and validate a subscription request with Apple.

Subscription keys are generated and the Users and Access section of App Store Connect, and you can use the same subscription key for all of your offers.

Click Generate Subscription Key, you'll be prompted to enter a name for the key.

Once your key is generated, it will appear in Active Keys and you get one shot to download it.

Click Download API Key and store the file in a safe place, you'll need to upload this to RevenueCat in the next step.

2. Add Subscription Key to RevenueCat

Once everything is set up in App Store Connect, you need to upload the Subscription Key from the previous step to RevenueCat. RevenueCat will handle all the server-side authentication and validation of the Subscription Offers.

Navigate to your app Settings in the RevenueCat dashboard.

In your app Settings you'll see an area to upload your Subscription Key .p8 file that you downloaded from App Store Connect.

3. Show Subscription Offer to desired users

It's up to you to decide which users you want to present a Subscription Offer to. The only eligibility requirements are that the user had (or currently has) an active subscription. Apple automatically enforces this requirement for you - if it's not met users be shown the regular product regardless of the offer you try to present.

Fetch payment discount

Before you can present a Subscription Offer to a user, you first need to fetch the SKPaymentDiscount. This is done by passing the SKProductDiscount and SKProduct to the .paymentDiscount method, which uses the Subscription Key from Step 2 to validate the discount.

Purchases.shared.paymentDiscount(for: product.discounts[0], product: product, completion: { (discount, error) in
    
    if let paymentDiscount = discount {
        
        // Payment discount fetched
    }
})
[RCPurchases.sharedPurchases paymentDiscountForProductDiscount:product.discounts[0] product:product completion:^(SKPaymentDiscount * _Nullable discount, NSError * _Nullable error) {
    if (discount) {
    // Payment discount fetched
  }
}];
const paymentDiscount = await Purchases.getPaymentDiscount(product, product.discounts[0]);
if (paymentDiscount) {
    // Payment discount fetched
}

Purchase product discount

After successfully fetching the SKPaymentDiscount, you can now display the Subscription Offer to the user however you'd like. If the user chooses to purchase, pass an SKProduct and SKPaymentDiscount to the .makePurchase method.

Purchases.shared.purchasePackage(package, discount: paymentDiscount, { (transaction, purchaserInfo, error, cancelled) in
    if purchaserInfo?.entitlements.all["your_entitlement_id"]?.isActive == true {
        // Unlock that great "pro" content
    }
})
[RCPurchases.sharedPurchases purchasePackage:package withDiscount:discount completionBlock:^(SKPaymentTransaction * _Nullable transaction, RCPurchaserInfo * _Nullable purchaserInfo, NSError * _Nullable error, BOOL userCancelled) {
  if (purchaserInfo.entitlements["your_entitlement_id"].isActive) {
    // Unlock that great "pro" content    
  }
}];
const purchaseMade = await Purchases.purchaseDiscountedPackage(package, paymentDiscount);

Next Steps

  • For a guided walkthrough of implementing Subscription Offers into a Swift app check out our blog

Updated about a month ago


iOS Subscription Offers


Implementing iOS Subscription Offers with Purchases SDK

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.