Auto-renewable subscriptions are great. They can help bring your already-pretty-awesome app to the next level and help you earn some extra money along the way. If your app offers consistent or renewable content or collections, adding support for In-App Purchase (IAP) subscriptions may be a good idea.
Auto-renewable subscriptions provide a way of offering your users continuous access to your app’s renewing content – providing them with a great user experience and access to content they care about while giving you an appealing business model.
With auto-renewable subscriptions, you don’t have to stick with the old 70/30 revenue split Apple usually offers. As an incentive for you to offer great ongoing value to your users, Apple will increase your share to 85% at the start of the second year of subscription.
Are you already convinced that your app can benefit from auto-renewable subscriptions? Great, because in this tutorial you’ll learn to do just that.
A couple important things to mention up front. The first is that for this tutorial — and working with IAP in general — you will need a paid Apple Developer account. The free version won’t allow you to set up in-app purchases. Second is you will need to use a real device for this tutorial. Simulators do not support in-app purchases.
To demonstrate the process of adding auto-renewable subscriptions to your app, you’ll use the awesome “Words of Wisdom by Winnie the Pooh” app. It’s a very simple looking app that works great for demonstrating IAP subscriptions.
The initial version of the app offers a single auto-renewable IAP – the right to receive random words of wisdom from Winnie the Pooh for one whole month! This is enough to brighten anyone’s day. But since it’s clear that people will want to continue using it for longer, you should also offer a yearly subscription option. This will prove more valuable to the app’s loyal users.
But, before diving into the implementation details, you may want to take a look at In-App Purchase Tutorial: Getting Started, which provides detailed explanations of the basics of working with Apple’s IAP in general. In this tutorial, you’ll focus on topics that are unique to auto-renewable subscriptions and refer back to the Getting Started guide for more details on general IAP topics.
A couple of disclaimers that are important enough to mention here:
- In the sample app, you’ll use hard-coded Product Identifiers. In real life, you’d prefer the flexibility of fetching these from a server.
- You’ll use
UserDefaultsto indicate that a user has purchased a product. In a real app, you’ll need to perform receipt validation and not save this indication locally.
So, with that out of the way, please download the app using the Download Materials button at the top or bottom of this tutorial.
Setting Up the Project
OK, so you have the starter project. Getting it to work will require you to make changes in both the project itself and on App Store Connect. Once you complete all of these steps, you’ll have a working app with a single auto-renewable subscription product.
In the process of creating an auto-renewable subscription, App Store Connect will ask you to define a subscription group. A subscription group is basically a collection of subscription products. You can learn more about subscription groups in the next section, but for now, just create a new subscription group for your new auto-renewable subscription. Call it PoohWisdomSubs.
Make sure you complete all of the meta-data for the newly created In-App Purchase, including the Review Information. You can use this image for the review screenshot.
Note the Subscription Duration field, which is specific to Renewable Subscriptions. This is the time duration after which the subscription will be automatically renewed unless the user opts out. In many cases, the only difference between the various IAP options your app offers will be the subscription duration and the price associated with it. The content itself won’t change — your users will be able to choose between multiple subscription options in order to get access to the same content.
Set the duration to 1 Month and the Subscription Price to $0.99 USD.
Once you’re done, the status of your new In-App Purchase will show as Ready to Submit.
- Create an App ID in the Apple Developer Portal. Be sure to use an Explicit App ID and make a note of the Bundle ID you use.
- Be sure you’ve accepted all legal agreements in App Store Connect, or you won’t see the right options in the following step. See Checking Your Agreements in the Getting Started tutorial if you need help.
- Create an iOS App in App Store Connect using said Bundle ID.
- Create an IAP Auto-Renewable Subscription product. Read below for some notes as you fill out the required fields.
- Copy your App and Product IDs from the previous steps for easy access.
- The last thing you need to do before moving back to the project is to create a sandbox user for testing. Remember, you need to use a real email address — one that you actually have access to, so that you can verify the account.
OK, now time to start on the project! Just a few more steps and you’ll have a working initial app:
- Set the Bundle Identifier to the one you created.
- Switch the Team on the General tab to your developer team.
- Search for com.razeware.poohWisdom.monthlySub and replace it with the Product ID of the IAP you created.
Tap your Apple ID and then tap Sign Out. At this point don’t actually sign in with the sandbox user. You’ll do this when you attempt to buy the IAP in your app.
Build and run the project, and you’ll see this in the project console:
Not purchased: $MyIAPID Loaded list of products... Found product: $MyIAPID $GroupID $Pricing
If you see this — congratulations! You have a working app with an auto-renewable IAP. But don’t get too comfy. You’re just getting started.
If you see something else, make sure you didn’t miss anything in the above steps:
- Did you set everything up on App Store Connect?
- Is your new IAP product status Ready to Submit?
- Did you set your Team and Bundle Identifier on your project’s General tab?
- Did you replace com.razeware.poohWisdom.monthlySub with your own product ID?
- Did you accept all of the agreements in App Store Connect, and do they all show as Active?
Type in the username and password of the sandbox account you created on App Store Connect, tap Continue and then OK on the following popups. If all goes well, you should now see your very first Winnie the Pooh quote! I hope it’s a good one! :]
If you’re interested in learning more about StoreKit and everything that went on behind the scenes when you tapped the Purchase button, check out the great Getting Started tutorial (I promise this is the last time I’ll refer you to it).
OK, now that you got that out of the way, you’ll dive into auto-renewable subscription specifics, starting with subscription groups.