I have used the In-app billing library for adding subscriptions in my app. Everything is working properly but I am unable to find how do I get a Users current active subscription?
As per the docs, the method queryPurchaseHistoryAsync
returns the most recent purchase made by the user for each SKU, even if that purchase is expired, canceled, or consumed. Due to this, I am unable to know whether a current subscription is active or not.
According to this post, if we cancel the subscription, it will still be considered active for that day. But I am getting the subscriptions in the response which were canceled before 15 days.
Any help will be appreciated. Thanks in advance.
To query users subscription i use this method:
public void querySubscriptions() {
Runnable queryToExecute = () -> {
Purchase.PurchasesResult purchasesResult = mBillingClient.queryPurchases(BillingClient.SkuType.SUBS);
if (mBillingClient == null ||
purchasesResult.getResponseCode() != BillingClient.BillingResponse.OK) {
return;
}
mPurchases.clear();
onPurchasesUpdated(BillingClient.BillingResponse.OK, purchasesResult.getPurchasesList());
};
executeServiceRequest(queryToExecute);
}
If you need more details, ask.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With