When I started developing apps last summer, I noticed that many developers recommend using RevenueCat for building subscription paywalls. I was surprised because Apple offers its own solution, StoreKit, but I figured people might prefer RevenueCat for its extra features.
Before I go further, let me mention that I’m an indie developer who only creates apps for Apple platforms. After looking into RevenueCat’s features, I realized it wasn’t the right fit for me because:
- I don’t develop for Android, so I don’t need a central place to manage subscriptions.
- I prefer using native solutions over third-party services when possible.
- I don’t want to increase my app size by adding extra packages.
- I don’t want to store my data on someone else’s servers.
- My apps don’t have millions of users, so A/B testing for my paywall wouldn’t give reliable results.
- I don’t want to give up part of my sales, even if that cut only applies after reaching $2.5K.
- I don’t want to depend on a third-party service for a core feature of my business.
So, I chose to stick with StoreKit for managing subscriptions and the paywall. I’m not saying RevenueCat is a bad choice, just that after evaluating both, StoreKit made more sense for my needs. Your situation may be different.
That said, choosing StoreKit meant I was going to miss out on one of RevenueCat’s useful features: subscription notifications. This feature works with App Store Connect and sends you notifications for new subscriptions, renewals, or cancellations. I saw a lot of people sharing these notifications and thought it would be nice to have them for myself (not to share, just to keep track). So, I started looking for a way to get similar notifications without spending money. And since you’re reading this, you probably guessed that I found a simple solution.
The Setup
To receive subscription notifications, you need two services: CloudKit and Cloudflare. I use Cloudflare to create the webhook that handles subscription requests. Then, in the same webhook, I send a request to CloudKit to trigger the notification. I’ll share the code and an example app, so you can just update the credentials and start receiving notifications right away.
Setting up CloudKit
First, you need an app to receive notifications. You don’t have to release this app, but you do need an Apple Developer account because CloudKit won’t work without it. I’ve created an app for this purpose, which you can clone from GitHub to your local machine. Open the project in Xcode and go to the Signing & Capabilities section for your app target. Make sure you have iCloud capability added, the CloudKit option checked, and a container selected. If there’s no container, create one with a name like “iCloud.com.yourname.UncleTim”.
Next, create an API key to access that container via CloudKit. Go to the CloudKit Console and select the CloudKit Database. At the top left, choose the bundle ID of your app. Then, in the left sidebar, click Tokens & Keys. Click the plus button next to Server-to-Server Keys and follow the steps to create a public-private key pair, then click Save. Once saved, CloudKit will show you the details of that key, including the Key ID. Save this Key ID because we’ll need it later.
When you run the first command during key generation, it creates a file called eckey.pem
. This file contains your private key, which we’ll use in the next step.
Creating the Table
This system works by using CloudKit’s public database. We’ll subscribe to this database for updates from the app, so whenever a new record is added, you’ll get a notification. The worker will create this record whenever Apple calls the worker endpoint on Cloudflare.
To set this up, create a new record in the CloudKit container with the following fields:
- title – STRING
- content – STRING
- date – DATE/TIME
Once the record is created, go to the Indexes page under Schema and create an index for the date field as SORTABLE and recordName as QUERYABLE. This ensures that the notifications in the app can be ordered by date.
Setting up the Cloudflare Worker
Now that the CloudKit setup is complete, it’s time to set up Cloudflare. First, if you don’t have a Cloudflare account, create one. Then, visit this GitHub repo and click Deploy with Workers to follow the steps for deployment. After it’s deployed, go to the worker’s settings page. In the Variables and Secrets section, you’ll need to enter the Key ID and Private Key from the previous step. (Be sure to copy the key between -----BEGIN PRIVATE KEY-----
and -----END PRIVATE KEY-----
and make it single line.) Also, ensure that the container ID matches the one from CloudKit. Once you’ve entered the secrets, copy the worker URL from Domains & Routes.
Setting up the App and Testing
With everything set up, you can now test the flow. First, run the Uncle Tim app on your iPhone via Xcode. When the app opens, allow notifications, this will also subscribe to the table for changes. Uncle Tim is now ready to receive events from any of your apps.
Next, go to the App Store Connect page of one of your apps that has subscriptions enabled. Under App Information, scroll down to the App Store Server Notifications section. Click Set Up URL under Sandbox Server URL and add the worker URL from Cloudflare (ending in .workers.dev
), then save it.
Now, create a subscription event for that app by running it on your iPhone through Xcode. Make sure you don’t use a StoreKit Configuration , as we need the Sandbox environment for testing.
Once the app is running, buy a subscription. After completing the transaction, you should receive a notification in the Uncle Tim app. If everything works as expected, you can now add the same worker URL to the Production Server URL for the app, and start receiving notifications from the production environment. You can also add the URL to other apps. Don’t forget to remove the worker URL from the Sandbox Server URL, or you’ll keep receiving notifications from the sandbox environment.
Debugging
If things aren’t working, you can check the worker’s logs in Cloudflare to see if the worker received the notification. The logs will also show the payload of the event. If needed, you can modify the content of the notifications by editing the worker.
I hope you found this article helpful! Now that you can receive notifications for your subscriptions, you might also want to track more details about your sales on your iPhone. For that, check out my app, Peek. It helps you monitor your app sales and trends. You can also use it to track your keyword rankings now, with more features coming in the future.