Skip to main content
Question

What strategy to use to notify the backend when an anonymous user becomes a logged in user?

  • 7 October 2024
  • 1 reply
  • 16 views

Forum|alt.badge.img+6
Hi guys,
 
We have the following scenario : 
- User is anonymous in the app, purchase subscription.
- RevenueCat associates subscription with that anonymous user ID.
- Our backend receives webhooks for the INITIAL_PURCHASE associated with the anonymous user id.
- User signs up with our backend. User is attributed a unique user ID.
- Our backend is unaware that the user has a subscription.
- When the mobile apps tries to access some features (let's say GET /documents), they get an unauthorized error.
 
Currently, the strategy we plan to use is to explicitly refresh a user subscription when the user tries to access the feature (GET /documents) and has no associated subscription. This means the feature is not paywalled in the mobile app, so the mobile app is aware of a subscription but not the server.
 
Do you have any other strategies to deal with this? 
This post has been closed for comments

1 reply

Ryan Glanz
RevenueCat Staff
Forum|alt.badge.img+8
  • RevenueCat Staff
  • 364 replies
  • October 9, 2024

It sounds like you have a couple options here:

  1. Follow these instructions to only generate custom IDs, so you don’t have to worry about aliases
  2. Continue to call our GET /subscribers endpoint when the user tries to access something protected (we will return the subscription for the custom id, if it is aliased to the anonymous id).
  3. Do the same as step 2, but store the subscription in the custom id’s attributes on your backend, so you don’t have to make a request to our servers every time. (You’ll want to keep this updated in the case of cancellations, expirations, etc)

If it’s not too disruptive to your UX, option 1 is likely the simplest route


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings