Google-IAP icon indicating copy to clipboard operation
Google-IAP copied to clipboard

How to check if the user has an active subscription in Android, Google Play?

Open DanielBarcenas97 opened this issue 4 years ago • 3 comments

How to check if the user has an active subscription in Android, Google Play?

DanielBarcenas97 avatar Sep 23 '21 08:09 DanielBarcenas97

did you find a solution to this problem?

Emranul-Islam avatar Jan 18 '22 11:01 Emranul-Islam

I personally haven't played much with subscriptions but I could look into this the coming weekend.

akshaaatt avatar Jan 18 '22 11:01 akshaaatt

 iapConnector?.addSubscriptionListener(
            object : SubscriptionServiceListener {
                override fun onSubscriptionRestored(purchaseInfo: DataWrappers.PurchaseInfo) {
                    // will be triggered upon fetching owned subscription upon initialization
                  //purchaseInfo.sku  is the id of Subscription
                }

                override fun onSubscriptionPurchased(purchaseInfo: DataWrappers.PurchaseInfo) {
                    // will be triggered whenever subscription succeeded
                }

                override fun onPricesUpdated(iapKeyPrices: Map<String, DataWrappers.ProductDetails>) {
                    // list of available products will be received here, so you can update UI with prices if needed
                }
            })

//this overrided method (onSubscriptionRestored()) will fetch active subscription for you.
//This method is will fetch  active subscription also working when user reinstall app.

dhirajved avatar Jul 27 '22 07:07 dhirajved