Hello,
Im am going through the firebase docs for the implementation and I am on the final stage, where I check the entitlements via the firebase claims with the code below
getAuth().currentUser.getIdTokenResult() .then((idTokenResult) => { // Confirm the user has a premium entitlement. if (!!idTokenResult.claims.activeEntitlements.includes("premium")) { // Show premium UI. showPremiumUI(); } else { // Show regular user UI. showFreeUI(); } }) .catch((error) => { console.log(error); });
When I go to check the active entitlements with the code like so console.log(idTokenResult.claims.activeEntitlements) it returns undefined and when I check the returned object of just console.log(idTokenResult.claims) activeEntitlements doesn’t exist. Also I enabled claims in the firebase setup
What can possibly be the fix for this? Thanks
Firebase implementation, ERROR Cannot read property 'includes' of undefined
Hey
Since it sounds like the `activeEntitlements` property doesn’t exist, I think you’ll want to first check if that property exists before trying to access it. It’s possible the user hasn’t had any data synced at the point in time you’re checking.
If you’re just looking to check entitlement access on your device, it may be easier and more reliable to use our SDK directly: https://www.revenuecat.com/docs/customer-info
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.