I’ve been working on integrating RevenueCat into my iOS app. The app itself is super simple but it comes with some app extensions. The extensions themselves don’t have access to internet (yes, that’s a restriction). Therefore, I’m using a group user defaults to share the subscription states between the app and the extensions.
Now, the app itself mostly won’t be opened by the user often, which has caused an issue as follow:
- The user opens the app and subscribes to be a Pro.
- The app shared the Pro status via user defaults with the extensions.
- Every time the extension is running, it checks the user default value and decide what entitlement the user has.
- After a while, the user cancels the subscription in the App Store subscription management screen. The subscription ends soon after that.
- The extensions still think the user has the Pro subscription because the user hasn’t opened the app since then.
How do I make sure the subscription state is updated in a timely manner when the app itself is mostly running in the background and the extension doesn’t have access to internet?
The only solution I have in mind is to have a backend service registering to the subscription state Webhook. The app will also register for the background push notification (no need user permission). And then whenever the user cancels the subscription in the Store, the server will just send a background push to the corresponding app and the app can pull the state and update the user default.
However, this solution has two issues:
- The user can disable background push via the system Setting manually.
- It requires a backend service with database for the push tokens.
Is there any recommendation from your side? Thanks in advance!