Last month, we wrote about Apple’s new iOS Subscription Offers, and today, we’re excited to announce official support for Subscription Offers! Below we’ll walk through a simple example of using RevenueCat to show a retention Subscription Offer to a user who has recently cancelled.
To learn more about what Subscription Offers are, and if they make sense for your app, check out our original post here.
Our journey into Subscription Offer land starts by stepping into App Store Connect to set up our offer. If you already have your offers set up in App Store Connect, head to Step 2.
Subscription Offers are included as a pricing option to an existing subscription product. When you click the “+” option next to Subscription Prices, you’ll see a new option to Create Promotional Offer.
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. The product code doesn’t need to be shared with users (though you could depending on your use case).
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:
For this example, we’re going to choose a Pay up front offer, and try to win back lapsed premium users with 3-months access for only $0.99 (what a deal!). Hopefully, after the 3-month offer users will stay subscribed.
Don’t forget to click Save in the upper right after you configure the offer!
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, we’ll need it later!
Now that everything is set up in App Store Connect, it’s time to start building our offer.
The last thing we need to do before we jump into some code is upload the Subscription Key that we generated in the previous step to RevenueCat. RevenueCat will handle all the server-side authentication and validation of the Subscription Offers.
RevenueCat: Hard at work authenticating your 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. That’s all there is to it!
Upload your Subscription Key file to RevenueCat and you’re good to go
Only users who had an active subscription in your app at some point (including current subscribers) are eligible for Subscription Offers. Just like trial eligibility, Apple doesn’t directly tell you if a user is eligible, so you need to check yourself. However, Apple will enforce this from a payment perspective, they will just be shown the regular product, regardless of the offer you try to present. This could create an awkward customer experience if you tell a user to redeem and offer and then presented the normal price.
In this example, I only want to show my Subscription Offer to users who had their paid subscription expire over 7-days ago — hopefully they’ll be willing to subscribe again if I give them a deal.
Feel free to get creative with how you choose to offer these promotions!
I won’t be recreating an entire app from scratch, let’s start with the SwiftExample that’s included in the Purchases iOS repo. This app lets you subscribe to see happy cat emojis, non-premium members can only see sad cat emojis. You can get the starter code for this app here.
We’ll use our SwiftExample app as the base for adding Subscription Offers.
CatsViewController.swift is the main view controller for the cat content in our app. This is where we’ll determine if we should present the user with a Subscription Offer.
Lets write a function to check if we should present this offer to the user:
Our requirements are fairly simple, we want to show the offer to any user that is still using the app at least 7-days after their ‘premium’ subscription has expired. We’re also checking a flag in UserDefaults to see if they’ve already been presented this offer. Not everyone will want to redeem the offer, so we’ll consider them ineligible if we’ve ever shown it before.
Next, let’s add this check to the end of our existing function that configures the view.
If it’s determined we should show a user the Subscription Offer, we’ll add a 2-second delay before presenting them with the offer to smooth out the UX a bit. Also, since we want to target iOS versions below 12.2, we wrap everything in an
if #available(iOS 12.2, *). The details of the
showOfferUpsell() function are covered in the next step!
At this point, we’ve set up a Subscription Offer and determined that we want to present the current user with the option to buy the offer.
We’ll add a function,
showOfferUpsell(), that asks the user if they’d like to redeem the offer — and if so, we continue with the purchase. The first step is to retrieve the offers and validate them with the Subscription Key we downloaded earlier. If the offer is valid, we present the user with the option to purchase it. Finally, if the user agrees, we make a purchase of the product with the Subscription Offer applied.
There’s a lot going on here, so we’ll first break down this function piece-by-pice, then show the entire function code after.
1. First we need to get the SKProduct (
product) and the SKProductDiscount (
productDiscount) for the Subscription Offer we want to show. We use a couple of
guard statements here to make sure we’ve entered the right key names after fetching the entitlements.
2. With the SKProduct and SKProductDiscount in hand, the next step is to fetch the SKPaymentDiscount with the Purchases SDK’s new
.paymentDiscount method. This makes a call to the RevenueCat backend and signs the offer using the Subscription Key uploaded in step 2 to verify the request.
3. Once the SKPaymentDiscount is retrieved , we have everything we need to let the user redeem the offer. We use a helper method to present a simple UIAlertController to show the user that there is an offer available, and ask if they’d like to redeem it.
When the user agrees to the offer, we use the
.makePurchase method to pass in the SKProduct and SKPaymentDiscount from earlier. This will trigger Apple to display the default purchase prompt, asking the user to confirm their purchase. Once the purchase is complete, we can reconfigure the view to show the premium content (happy cat emojis)!
Wow that was a lot! Let’s check out the entire function below to help understand how everything works together:
When we put it all together, we should see a new purchase prompt from Apple which outlines the promo conditions.
Whew! Looks like our Subscription Offer is working and we’re ready to win back churned users!
Now that you have the tools to build and track Subscription Offers in your app, we wanna know what you use them for! This was just a simple example, and know you’ll be able to do a lot more than what we walked through here.
In the future, we’ll be adding features for deploying win-backs, referrals and other incentives, but want to hear from you. If you have ideas or requests for this feature, comment about it on our our discussion boards or email. As always, we are available to help you in any way we can, so don’t be shy about reaching out.
You can download the complete example app here.
For more updates, tip, and tricks follow us on Twitter!