I am using the com.android.billingclient:billing:3.0.1 library. How can I check if the user has purchased any product when the app is opened. So I want to check before the payment page opens.
The following method returns null:
mBillingClient = BillingClient.newBuilder(getApplicationContext()).enablePendingPurchases().setListener(this).build();
mBillingClient.queryPurchaseHistoryAsync(BillingClient.SkuType.INAPP, new PurchaseHistoryResponseListener() {
@Override
public void onPurchaseHistoryResponse(@NonNull BillingResult billingResult, @Nullable List<PurchaseHistoryRecord> list) {
list.size();
}
});
You can use
GetPurchasesHistory
method to get purchased items. This is working for me perfectly. So you can use that :)