BillingClient offers a method named isFeatureSupported(). The documentation for the int returned is:
BILLING_RESULT_OK if feature is supported and corresponding error code otherwise.
I could not find BILLING_RESULT_OK to be defined anywhere. It is not among the constants defined in BillingClient.BillingResponse. Should I just use
BillingClient.BillingResponse.OK
?
in 2019 running 'com.android.billingclient:billing:2.0.1'
replace:
BillingResponse.OK
with
BillingClient.BillingResponseCode.OK
The whole documentation feels very unprecise. Shocking to see how weak Google handles this.
I believe that's a typo in the documentation. Instead, you should use BillingResponse.OK
: https://developer.android.com/reference/com/android/billingclient/api/BillingClient.BillingResponse#ok
You can see it in use in this example: https://github.com/googlesamples/android-play-billing/blob/master/TrivialDrive_v2/shared-module/src/main/java/com/example/billingmodule/billing/BillingManager.java#L126
For me useing BillingClient.BillingResponse.OK
did not work, it always acts like if the feature is not supported. I had to use this:
int response = billingClient.isFeatureSupported(BillingClient.FeatureType.SUBSCRIPTIONS);
if (response == BillingClient.BillingResponse.FEATURE_NOT_SUPPORTED) {
Toast.makeText(this, "Feature not supported", Toast.LENGTH_SHORT).show();
return;
}
So whole check for "com.android.billingclient:billing:2.0.3" looks like this:
public boolean isSubscriptionsSupported() {
if (myBillingClient != null) {
BillingResult isSubscriptionsSupported = myBillingClient.isFeatureSupported(BillingClient.FeatureType.SUBSCRIPTIONS);
return isSubscriptionsSupported.getResponseCode() == BillingClient.BillingResponseCode.OK;
}
return false;
}
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