Solved

Check subscription status

  • 24 February 2022
  • 1 reply
  • 576 views

Badge +2
  • New Member
  • 4 replies

Hi, I have some confusion between

if let info = purchaserInfo {

if info.allPurchasedProductIdentifiers.contains("xxx") {

and

 if purchaserInfo?.entitlements["pro"]?.isActive == true {

Basically, i am trying to check if the user has subscription or not. I am checking with .onAppear in the default main view. I am new and would like to learn how to check if the user subscription period hasnt finished (doesnt matter if the user cancelled the subscription or not, of course)

icon

Best answer by joshdholtz 24 February 2022, 20:29

View original

1 reply

Userlevel 3
Badge +5

Hey @dfx!

You will most likely want to use…

if purchaserInfo?.entitlements["pro"]?.isActive == true

Entitlements (through the RevenueCat dashboard) can be attached to multiple different products (whether they are subscriptions or non-consumable/lifetime purchases). These makes it easier because you only need to look for “pro” instead of checking for a handful of different product identifiers that could change. Entitlements will also get removed (or be marked as non-active) when a subscription expires. Looking for entitlements is what you will most likely want to use when checking to unlock content based on subscription status and/or lifetime unlocks.

On the other hand, `allPurhcaseProductIdentifiers` is more like a transaction history kind of thing but won’t provide you with information about subscription status and will be more difficult to check as you will need to keep the product identifiers hardcoded in your app.

There are some more docs here if you haven’t checked these out yet! https://docs.revenuecat.com/docs/purchaserinfo

Hope this helps! Let me know if there is anything else I can clarify 😊 

Reply