Skip to main content
Solved

Claims are not updated after collections are updated by subscriptions cancelled

  • September 13, 2024
  • 5 replies
  • 47 views

Forum|alt.badge.img+2

When RevenueCat update firestore collection to indicate that subscription is cancelled claims are not updated.

Scenario to proof : 

-  Cancel your subscription and create a listener on the collection containing the subscription data.

-  Once subscription is updated by RevenueCat at ‘expiresDate’ your app will be notified.

-  Once notified call FirebaseAuth.instance.currentUser!.getIdTokenResult(true).
-  As you can see claims are not updated

Because of that, after subscription i can’t read some collections protected by firestore rules using claims.

Best answer by enguerrand-arminjon-d1b39e

Today I definitely remove all reference of firebase claims and I only use Firestore and firestore query inside my Firestore rules. That make few additional reads but I no longer have issues.

 

I really suggest to NOT follow RevenueCat doc with Firebase Claims. Both are not ready for PROD usages.

 

RevenueCat should I believe edit the documentation to not use RevenueCat Firebase Extension claims property as it didn't work. 

View original
Did this post help you find an answer to your question?
This post has been closed for comments

5 replies

jeffrey_bunn
RevenueCat Staff
Forum|alt.badge.img+6
  • RevenueCat Staff
  • 250 replies
  • September 17, 2024

Hi @enguerrand-arminjon-d1b39e! In this scenario, is the subscription immediately cancelled? Or have you set the subscription to “not renew”? Custom claims are based on entitlements, so if the subscription hasn’t fully expired, the entitlement will still be active for the user and won’t be removed.


Forum|alt.badge.img+2

When cancellation is cancelled and exceed limitation date (a canceled subscription can still be valid few minutes I know and that's why I listen Firestore) : firestore is well updated but claims are not at same times. If after store update I force refresh my claims using getIdTokenResult(true) I get the old claims... But if I wait a bit like 1 minutes I can we'll see claims updated...

 

So claims are asynchronously updated after store update instead of before or at same times...


Forum|alt.badge.img+2

Today I definitely remove all reference of firebase claims and I only use Firestore and firestore query inside my Firestore rules. That make few additional reads but I no longer have issues.

 

I really suggest to NOT follow RevenueCat doc with Firebase Claims. Both are not ready for PROD usages.

 

RevenueCat should I believe edit the documentation to not use RevenueCat Firebase Extension claims property as it didn't work. 


jeffrey_bunn
RevenueCat Staff
Forum|alt.badge.img+6
  • RevenueCat Staff
  • 250 replies
  • September 20, 2024

@enguerrand-arminjon-d1b39e Thanks for the additional information. Custom claims are set within the same function as the Firestore data. You can see in the main handler function of the integration that setCustomClaims is called just after the Firestore events and customers collections are updated.


Forum|alt.badge.img+2

An alternative can be to listen to events (from eventChannel) to know when refresh claims. Interesting, one key point is to achieve that also on app launch to avoid keep old claims → that required to implement a little logic.

Interessting i totaly forgot that revenuecat firebase extension is open source.

ty :).


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