How do I check the user's eligibility for intro pricing and free trials on Android? | RevenueCat Community
Skip to main content
Solved

How do I check the user's eligibility for intro pricing and free trials on Android?


Forum|alt.badge.img+5

I have set up various products on play store and am able to fetch them successful via the Purchases.sharedInstance.getOfferingsWith function. 

Some of my products have introductory pricing and/or free trials. I have tried testing this functionality and it seems to work. The problem I am running into now is if I have a user that has made use of the free trial or intro pricing for the subscription, cancels the subscription, and then wants to resubscribe I don’t appear to have a way to tell that the user is not longer eligible for intro pricing or free trials. The only way to tell is only after the user has started to go through the play store billing flow, but I need to display the correct information about the product in my app’s UI.

Best answer by sharif

Since there’s no checkTrialOrIntroductoryPriceEligibility method on Android, you have to manually check whether a product has been purchased before showing an intro offer.

If you attach your products to entitlements, this can be done by looping over the EntitlementInfos found in the PurchaserInfo (Kotlin and Java save you from looping by using the isNotEmpty() method):

if (purchaserInfo.entitlements.all.isNotEmpty()) {
    // user has had access to an entitlement which means they're not eligible for the offer
    // remove offer messaging
} else {
    // user has never had access to any entitlements
    // show intro offer
}

If you want to check whether a user has ever had access to a specific entitlement:

if (purchaserInfo.entitlements["your_entitlement_id"] != null) {
    // user has had access to "your_entitlement_id" which means they're not eligible for the offer
    // remove offer messaging
} else {
    // user has never had access to "your_entitlement_id"
    // show intro offer
}

If you don’t use entitlements, you’ll have to use the allPurchaseDatesByProduct property of the PurchaserInfo to check if a product has been previously purchased.

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

sharif
RevenueCat Staff
Forum|alt.badge.img+9
  • RevenueCat Staff
  • July 23, 2021

Since there’s no checkTrialOrIntroductoryPriceEligibility method on Android, you have to manually check whether a product has been purchased before showing an intro offer.

If you attach your products to entitlements, this can be done by looping over the EntitlementInfos found in the PurchaserInfo (Kotlin and Java save you from looping by using the isNotEmpty() method):

if (purchaserInfo.entitlements.all.isNotEmpty()) {
    // user has had access to an entitlement which means they're not eligible for the offer
    // remove offer messaging
} else {
    // user has never had access to any entitlements
    // show intro offer
}

If you want to check whether a user has ever had access to a specific entitlement:

if (purchaserInfo.entitlements["your_entitlement_id"] != null) {
    // user has had access to "your_entitlement_id" which means they're not eligible for the offer
    // remove offer messaging
} else {
    // user has never had access to "your_entitlement_id"
    // show intro offer
}

If you don’t use entitlements, you’ll have to use the allPurchaseDatesByProduct property of the PurchaserInfo to check if a product has been previously purchased.


Forum|alt.badge.img+4
  • New Member
  • July 31, 2021

With this method you can’t detect if an user was suscriber without use a trial/intro period. So this works only if all your suscriptions has intro/trial offer. What happens if the first subscription was without offer → Unsuscribe. If you send a trial offer this code wont show it, because the user had bought this entitlement before.


Forum|alt.badge.img+5
  • Member
  • September 20, 2021
sharif wrote:

Since there’s no checkTrialOrIntroductoryPriceEligibility method on Android, you have to manually check whether a product has been purchased before showing an intro offer.

If you attach your products to entitlements, this can be done by looping over the EntitlementInfos found in the PurchaserInfo (Kotlin and Java save you from looping by using the isNotEmpty() method):

if (purchaserInfo.entitlements.all.isNotEmpty()) {
    // user has had access to an entitlement which means they're not eligible for the offer
    // remove offer messaging
} else {
    // user has never had access to any entitlements
    // show intro offer
}

If you want to check whether a user has ever had access to a specific entitlement:

if (purchaserInfo.entitlements["your_entitlement_id"] != null) {
    // user has had access to "your_entitlement_id" which means they're not eligible for the offer
    // remove offer messaging
} else {
    // user has never had access to "your_entitlement_id"
    // show intro offer
}

If you don’t use entitlements, you’ll have to use the allPurchaseDatesByProduct property of the PurchaserInfo to check if a product has been previously purchased.

@sharif It seems that the Android wrapper (Unity SDK) is calling something when using the CheckTrialOrIntroductoryPriceEligibility method.

 

Is this not working or did it change recently?


Forum|alt.badge.img+5
  • Member
  • October 1, 2021

@sharif Any updates on this?


Forum|alt.badge.img+3
  • New Member
  • December 18, 2021

@sharif  Wouldn’t purchaserInfo.entitlements.all always return empty object if it is a new app user regardless if his Play Store account is eligible for free trial or not?

For example, a one time free trial was already used with Play Store account, but with different app account. As a result, by using this method we would display intro price and may confuse the user.


Forum|alt.badge.img+5
  • New Member
  • February 16, 2022

Also in my case purchaserInfo.entitlements.all is empty even though the user have already participated in the free trial. What to do @sharif ?


Forum|alt.badge.img+1
  • New Member
  • August 8, 2022

Is there any update on this?

I have one google account > I purchase a subscription > I make an app account >  I cancel the subscription, I delete the app > I reinstall the app >  (I have the same google account) > I present the user the available subscriptions without asking him to create an account : 

→ the way suggested by @sharif  will return me empty entitlements at this point, even if the same google play account had in the past a subscription. so, because of empty entitlements, I present to the user that he’s eligible for a trial subscription, but when the native google play dialog opens, user sees the message that he’s not eligible for a trial. 

purchaserInfo.entitlements.all   → will return the right entitlements only if you use the same app account, but users use the same google account but different app accounts.
 


Forum|alt.badge.img+5

@sharif Can you please clarify how we are supposed to handle the case outlined by @ghita above?

If I delete the user from RevenueCat, then recreate a customer with the same Google account, but a new ID in RevenueCat, you will tell me that the user is entitled to trial because there are no entitlements or previously purchased products, but Google Play will say “Not eligible for trial” when we try to purchase a subscription with trial for that same user.


Forum|alt.badge.img+3
  • Active Member
  • August 25, 2022

This is very important for my client too, the app has explicit trial text in key areas and that info has to be accurate for our users.

L.E.: Just to clarify, I’m talking about the case mentioned above, with different app accounts but the same Google account in the Google Play app.


cody
RevenueCat Staff
Forum|alt.badge.img+8
  • RevenueCat Staff
  • August 31, 2022

Hey all,

While a new app user would have empty entitlements, a workaround would be to call syncPurchases before manually checking eligibility as mentioned in Sharif’s comment.

This method will take the existing underlying purchases, re-sync with RevenueCat and transfer to the new user ID, and return CustomerInfo with information about the previous purchases (which you can then use to manually determine eligibility).


Forum|alt.badge.img+1
  • New Member
  • March 26, 2023

@Radu S  @ghita  What hack are you currently using to check for this at the moment?


Forum|alt.badge.img+3

While a new app user would have empty entitlements, a workaround would be to call syncPurchases before manually checking eligibility as mentioned in Sharif’s comment.

 

@cody Do we need to call syncPurchases if we call the logIn method before checking entitlements? Or is this required regardless to make sure everything is re-synced with RevenueCat? 


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