Reputation: 1700
in my android app i implemented the in App-Billing, where the user can buy a subscription in the app.
when the user launch the app, i want to check if he has any subscription at all, to decide which content should i show him.
i'm using the latest in-app-billing library implementation 'com.android.billingclient:billing:1.1'
thank you in advance for the help
Upvotes: 4
Views: 3971
Reputation: 1700
my goal was to find out, if the user has a subscription at all. i have resolved it like this.
mBillingManager = new BillingManager(this);
Purchase.PurchasesResult purchasesResult = mBillingManager.getPurchaseMadeByUser();
if(purchasesResult.getResponseCode() == BillingClient.BillingResponse.OK && (purchasesResult.getPurchasesList() != null)){
hasSubscription = true;
}
and everywhere in the app, i check if hasSubscription == true then don't load the ads.
to set up the In-App Billing in my App, i followed this Tutorial from Google : https://codelabs.developers.google.com/codelabs/play-billing-codelab/#0
Upvotes: 2
Reputation: 2631
You have two options
Refer this answer. It will give you some idea of In-app purchase workflow.
I also suggest you go through some articles about InApp purchase.
Upvotes: 2