Question

How can I sync subscription status when the app is in the background

  • 8 April 2023
  • 1 reply
  • 45 views

Badge +1

Hi team,

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:

  1. The user opens the app and subscribes to be a Pro.
  2. The app shared the Pro status via user defaults with the extensions.
  3. Every time the extension is running, it checks the user default value and decide what entitlement the user has.
  4. After a while, the user cancels the subscription in the App Store subscription management screen. The subscription ends soon after that.
  5. 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:

  1. The user can disable background push via the system Setting manually.
  2. It requires a backend service with database for the push tokens.

Is there any recommendation from your side? Thanks in advance!


1 reply

Userlevel 6
Badge +8

Hey @Jin Wang!

This seems like a pretty good workaround, even if users disable background push. If the extension can’t access the network for updates, and the app isn’t opened often, I’m not sure there is a great option for getting it refreshed.

You might be able to communicate with the user that they need to re-open the app periodically, but I understand that’s not totally ideal. I’ll leave this thread open in case others have run into the same type of issue.

 

Reply