Comments (5)
@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.
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.
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.
@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.
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)
- java.lang.NullPointerException
- Seeking Maintainer
- How to check if user has already purchased a product ? HOT 1
- How do I Use The Consume Product Product Feature
- onSkuResponse:: product id mismatch with Product type HOT 7
- UPDATE: v5 API Upgrade Require HOT 4
- issue in saveString method
- Exception java.lang.NoSuchMethodError
- working for all users without buy anithing.
- Client is already in the process of connecting to billing service ( ERROR ) HOT 4
- getSubscriptionListingDetailsAsync not loading subscription SKU details HOT 1
- https://videa.hu/videok/film-animacio/world-trade-center.mp4-ntneqHHjcnpfM7SI
- How to get the quantity of a consume product?
- Future Support for Billing Library version 5 or newer HOT 12
- SecurityException on Android 14 HOT 1
- You don't check if the `WeakReference` is still alive. I think you should also check if the reference is not yet enqueued.
- This is old code new update required...
- Security Exception in android 14 not resolved in v2.0.3 HOT 2
- Google not support library 4.0 , how to make this?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-inapp-billing-v3.