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
Asked
Active
Viewed 3,364 times
4

korchix
- 1,445
- 1
- 19
- 22
2 Answers
2
You have two options
- Create a WebAPI as Google suggest having a separate server which tracks users purchases and communicates with the Google APIs. Refer LINK.
- Use Google's InApp billing library to get users subscription.
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.

Kishan Vaishnav
- 2,273
- 1
- 17
- 45
2
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

korchix
- 1,445
- 1
- 19
- 22