Blog: Converting a Paid iOS App to Subscriptions

Making the Switch

RevenueCat's Purchases SDK is dead-simple to install and integrate into new and existing apps. If you haven't already, you'll need to register your app in RevenueCat before installing and initializing the SDK.

You can install the SDK by adding Purchases to your .podfile, or by adding the GitHub repo as a Swift package in Xcode. If you need to manually install the SDK, you can do that too. For more information about installing the SDK, check out our installation docs.

Setting Up Entitlements

An entitlement represents access to certain features and can be either active or inactive. In our case, we'll be switching a paid, premium app to free with subscription, so existing paid features will fall under a single entitlement that we will call “premium”. For more information about setting up entitlements, check out the full guide in our docs.

Entitlements become “active” when a purchase is made for a product that is attached to that entitlement. For a subscription product, the entitlement will be active for the duration of the subscription. If a subscription expires or is cancelled, the entitlement is deactivated at the end of the paid term.

We’re going to use the premium entitlement when we convert our paid app to free so we can continue providing premium features to paid customers.

Parsing Your App Receipt

Now that you have your app registered in RevenueCat, the SDK is installed, and you’ve created an entitlement, it's time to dig into device receipts.

Apple uses a binary receipt file to store data for purchases related to apps. These receipt files are complicated to sift through, but contain necessary information about the app download and purchase.

Each receipt contains the original_application_version parameter. On iOS, this corresponds to the build number of the version that the user first downloaded. This is the main way to determine a user’s entitlement access for paid versions. If a user's original_application_version is that of a paid version, you should grant paid access to a particular feature or entitlement.

Not only does the receipt need to be parsed, it also has to be validated. Client-side validation is challenging — you can't ensure the integrity of a receipt because jailbroken devices can spoof their on-device receipt.

Going into detail about how to parse and validate this receipt is a rabbit hole that is way outside the scope of this post. If you're interested in doing this manually, you'll need to validate receipts on your own server and securely provide the data back to your app.

But we don’t have to do any of that today — we're using RevenueCat!

Read more here

Was this article helpful?
0 out of 0 found this helpful