Git Product home page Git Product logo

Comments (5)

faizan-ali-brainx avatar faizan-ali-brainx commented on August 16, 2024

@pavelsust Faced the same issue. The only solution left for me was to use the official Google API to check this. Let me know if you need any help with that.

from android-inapp-billing-v3.

tripping-alien avatar tripping-alien commented on August 16, 2024

Hello @faizan-ali-brainx, could you explain your method please? I'm facing the same problem, it caches the result but it's unclear when does it refresh the cache.
Maybe it's possible to add a method to refresh the cache.

from android-inapp-billing-v3.

tripping-alien avatar tripping-alien commented on August 16, 2024

After successful subscription I had unsubscribe from my google play. But still, now I am getting purchaseData.autoRenewing true. So how I can solve this issue.

Is there any other way to know user unsubscribed from my service?

You should be using isSubscribed("aaa");

from android-inapp-billing-v3.

faizan-ali-brainx avatar faizan-ali-brainx commented on August 16, 2024

@tripping-alien Yes, the problem lies somewhere in cashing. When you subscribe for the first time. It always returns true from onward whether you cancel from the play store or your subscription expires. Yes, I was using the isSubscribed() method provided by the library. The pull request # 517 solved this issue I guess. Not sure though. Either you can wait for it to merge or solve it on your own. I didn't had time to wait this long so I opted to use the official Google API for this. You can use this or modify it according to your needs.

`class SubscriptionUtils() {

private val purchasesUpdatedListener =
    PurchasesUpdatedListener { billingResult, purchases ->

    }

fun startConnection(
    context: Context,
    isMonthlyOrYearly: (Boolean, Boolean) -> Unit
) {
    val billingClient = BillingClient.newBuilder(context)
        .setListener(purchasesUpdatedListener)
        .enablePendingPurchases()
        .build()


    billingClient.startConnection(object : BillingClientStateListener {
        override fun onBillingSetupFinished(billingResult: BillingResult) {
            if (billingResult.responseCode == BillingClient.BillingResponseCode.OK) {
                billingClient.queryPurchasesAsync(
                    BillingClient.SkuType.SUBS
                ) { code, list ->
                    if (list.size > 0) {
                        if (list[0].skus[0] == "Your subscription Id here") {
                            if (list[0].isAutoRenewing) {
                                // Your logic here
                                isMonthlyOrYearly(true,false)
                            }
                        }
                    } else {
                        isMonthlyOrYearly(false, false)
                    }
                }
            }
        }

        override fun onBillingServiceDisconnected() {
            // Try to restart the connection on the next request to
            // Google Play by calling the startConnection() method.
        }
    })
}

}`

And then simply call like this where you want to check

SubscriptionUtils().startConnection(this) { isMonthly, isYearly -> }

Here isMonthly or isYearly indicates whether your subscription was canceled or expired. True means yes and false means no. Happy coding!!!

from android-inapp-billing-v3.

lee4jun2 avatar lee4jun2 commented on August 16, 2024

When I used bp.loadOwnedPurchasesFromGoogleAsync, I got the correct autoRenewing value.

bp.loadOwnedPurchasesFromGoogleAsync(object: BillingProcessor.IPurchasesResponseListener{
            override fun onPurchasesSuccess() {
                if(bp.isPurchased(productId)){
                    // ~~
                }else if(bp.isSubscribed(productId)){
                     // ~~
                }else{
                    // ~~
                }
            }

            override fun onPurchasesError() {
            }

        })

from android-inapp-billing-v3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.