28

Is there any way how to check if user've already used his free trial?

When I query sub I got the next data:

[
    SkuDetails:{
        "productId":"...",
        "type":"subs",
        "price":"...",
        "price_amount_micros":0000,
        "price_currency_code":"USD",
        "subscriptionPeriod":"P1M",
        "freeTrialPeriod":"P1W1D",
        "title":"...",
        "description":"..."
    }
]

Will this field "freeTrialPeriod":"P1W1D" disappear when a user uses his free trial? Or maybe there's some other way to know it?

I need to show "free" instead of subscription price and then show actual price after user used his free trial

Oleksandra
  • 851
  • 9
  • 11
  • 2
    Did you have any luck in testing this? I'm also trying to implement your same requirements. – Damien Diehl Apr 11 '18 at 18:13
  • 1
    @DamienDiehl yes, it seems you receive "freeTrialPeriod":"P1W" regardless of it's availability for user. So you need to manage it manually. However when you do mSubHelper.launchPurchaseFlow(...), user will see if their trial period has expired in GooglePlay's popup, like this http://prntscr.com/j49fyq – Oleksandra Apr 12 '18 at 12:06
  • Yeah this is tricky, I'm finding that queryPurchases will not even necessarily return all previous purchases for a SKU, so we can't rely on that to determine if there is a free trial available. I'm still searching for solutions but I don't think there will be anything reliable :( – Damien Diehl Apr 12 '18 at 19:29
  • @DamienDiehl seems all you can do is save trial status after successful purchase. If you can identify user through your server, you may store the status there. Otherwise just store it localy and in case of reinstallation user will see "free trial" in the app and real status in GP popup. Also you may try to identify user by email (https://stackoverflow.com/a/2175688/7825979) but you need special permissions to do so, I don't think it's worth it :( – Oleksandra Apr 12 '18 at 20:24
  • Check my answer https://stackoverflow.com/a/52297772/5827565 – Pavel Poley Sep 12 '18 at 18:46
  • Has anyone tried using `BillingClient.queryPurchaseHistoryAsync()` for this? It should tell you if the user has ever purchased any subscriptions. – Lawrence Kesteloot Sep 10 '20 at 23:11
  • any answer to this question? – Eren Tüfekçi Jan 03 '21 at 12:05

1 Answers1

3

In the documentation, Google clearly emphasizes that this is Google Play responsibility to show the user that they have used the free trial.

Note: SkuDetails.getFreeTrialPeriod() returns the free trial period configured in Google Play Console. It's possible the user has already used a free trial. In this case, Google Play communicates to the user that they are ineligible for another free trial.

Free Trial Documentation

It means you can show the user (3 days free then price/time) always or you need to handle it manually (using shared preferences, your own server, using query purchase history async to keep shared presence status up to date in case of reinstalls)

Eren Tüfekçi
  • 2,463
  • 3
  • 16
  • 35