I am trying to create a in-app billing for android application that will allow users to buy a subscription. I have managed to do that and I am able to buy subscriptions but what I don't get is how can I limit some features in app to those who have not subscribed?
I cant seem to find any tutorials on that. What I want is on a button press if user have not subscribed prompt a in-app billing window. I can achieve that with this code.
public void launchBillingFLow(@SkuType String skuType, String productId) {
Runnable launchBillingRequest = () -> {
BillingFlowParams mBillingFlowParams;
mBillingFlowParams = BillingFlowParams.newBuilder()
.setSku(productId)
.setType(skuType)
.build();
mBillingClient.launchBillingFlow((Activity) context, mBillingFlowParams);
};
executeServiceRequest(launchBillingRequest);
}
But what if user have already subscribed? So the question is, how can I check if user is subscribed and execute button press and if not show billing window. Can I get that information only if user is connected to the Internet? Do I need to store that information on device?