Solved

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

  • 23 July 2021
  • 8 replies
  • 1535 views

Badge +4

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.

icon

Best answer by sharif 23 July 2021, 23:55

View original

8 replies

Userlevel 4
Badge +9

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.

Badge +4

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.

Badge +2

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?

Badge +2

@sharif Any updates on this?

Badge +3

@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.

Badge

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

Badge

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.
 

Badge

@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.

Reply