Skip to main content
Solved

Check subscription status

  • 24 February 2022
  • 1 reply
  • 1007 views

Forum|alt.badge.img+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)

Best answer by joshdholtz

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 😊 

View original
Did this post help you find an answer to your question?

1 reply

joshdholtz
RevenueCat Staff
Forum|alt.badge.img+5
  • RevenueCat Staff
  • 92 replies
  • Answer
  • February 24, 2022

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


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