I am using Play Billing Library v1.0
for one of my android application for subscription.
if (billingResponse == BillingClient.BillingResponse.OK) {
Purchase.PurchasesResult result = mBillingClient.queryPurchases(BillingClient.SkuType.SUBS);
if (result.getPurchasesList().size() > 0) {
if (result.getPurchasesList().get(0).getSku().equals(constant.sku_subscription_weekly)) {
premium= 2;
}
I am getting sku like above and providing benefit according to it on splash Screen. I have doubt that if membership expires what will happen in this ? It will return sku still ? I have tried to test using tester account and its not returning sku if we cancel it, but I am not sure for real purchase, there no any method for test real purchase below 7 days and I do not want wait for 7 days to test, Anyone can please confirm me about it ?
Once the subscription expires you will not receive SKU in getPurchaseList
. If the user is subscribed to only one subscription then getPurchaseList
will return zero.
Handle subscription expired with else
if (result.getPurchasesList().size() > 0) {
if (result
.getPurchasesList()
.get(0)
.getSku()
.equals(constant.sku_subscription_weekly)) {
premium = 2;
} else {
// TODO: subscription expired
}
} else {
// TODO: subscription expired
}