Question

How to sync user subscription status with my backend and use it for web app?

  • 20 October 2023
  • 3 replies
  • 223 views

Badge +2

Hello, Let’s say I have a project called Flexifit that is both on the mobile and the web.

I am using revenuecat to handle subscriptions on the iOs app, users are presented with a paywall before signin in, meaning that they could be a “pro” member without user account.

After they create account, how do I reliably “attach” the revenue cat user to my database user? Also on top of that what uniquely identifies the revenue cat user? is it the original_app_user_id or is the email address that is used to login to the app store? I want a single source of truth so that I could verify their subscription status no matter what device they are using.

The reason for this is that if user decides to go use the web version, I could check their pro status by calling my database and then checking what revenue cat user id belongs to the current user.


3 replies

Userlevel 4
Badge +8

Hi, for this linking you’ll want to use the original_app_user_id. But with this note that if users end up being merged together, this could change. In that case, the previous original_app_user_id can still be used to access the user as all app_user_ids for the user will be considered the same user. For events, this could change as it will be the last seen alias, in which case you can check the alias array in the event for the original_app_user_id you have stored in your database. See our docs here for more details: https://www.revenuecat.com/docs/aliases-card

 

App user ids uniquely identify RevenueCat users as each one is a unique value, but purchases from them can be transferred based on the underlying store account, i.e. their Apple/Play Store accounts. This is because purchases are linked to the customer’s store account, so if the customer logs into a different RevenueCat app user id with the same underlying store account as they used on another app user id, then these purchases will transfer based on your restore behavior, see here for more details: https://www.revenuecat.com/docs/restoring-purchases

Badge +2

Hi, for this linking you’ll want to use the original_app_user_id. But with this note that if users end up being merged together, this could change. In that case, the previous original_app_user_id can still be used to access the user as all app_user_ids for the user will be considered the same user. For events, this could change as it will be the last seen alias, in which case you can check the alias array in the event for the original_app_user_id you have stored in your database. See our docs here for more details: https://www.revenuecat.com/docs/aliases-card

 

App user ids uniquely identify RevenueCat users as each one is a unique value, but purchases from them can be transferred based on the underlying store account, i.e. their Apple/Play Store accounts. This is because purchases are linked to the customer’s store account, so if the customer logs into a different RevenueCat app user id with the same underlying store account as they used on another app user id, then these purchases will transfer based on your restore behavior, see here for more details: https://www.revenuecat.com/docs/restoring-purchases

So if I have 2 users:

My database user with id of John123 and revenue cat user id with id of revenuecatJohn123, how can I let revenue cat api know that John123 belongs to revenueCatJohn123 so that when John123 tries to use pro feature on my web app, I would make an api call to revenue backend to check if he has active subscription.

Can we attach metadata to user object in revenue cat?

Userlevel 4
Badge +8

Hi, yes you can attach metadata to users in RevenueCat but also note that in your database you may want to have the mapping where John123 has revenuecatJohn123. You can use a custom subscriber attribute to attach this metadata, please see our docs here for more details: https://www.revenuecat.com/docs/subscriber-attributes

 

Reply