[英]How to check if the user has bought a subscription
在我的Android應用程序中,我實現了App-Billing中的,用戶可以在其中購買應用程序中的訂閱。 當用戶啟動該應用程序時,我想檢查他是否有任何訂閱,以確定我應該向他顯示哪些內容。 我正在使用最新的應用程序內計費庫implementation 'com.android.billingclient:billing:1.1'
,在此先感謝您的幫助
我的目標是找出用戶是否有訂閱。 我已經解決了這個問題。
mBillingManager = new BillingManager(this);
Purchase.PurchasesResult purchasesResult = mBillingManager.getPurchaseMadeByUser();
if(purchasesResult.getResponseCode() == BillingClient.BillingResponse.OK && (purchasesResult.getPurchasesList() != null)){
hasSubscription = true;
}
在應用程序中的所有位置,我都會檢查hasSubscription == true,然后不加載廣告。
要在我的應用中設置應用內結算,我遵循了Google的以下教程: https : //codelabs.developers.google.com/codelabs/play-billing-codelab/#0
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.