PeterStaev / nativescript-purchase

:moneybag: A NativeScript plugin for making in-app purchases!
Apache License 2.0
83 stars 28 forks source link

Implement support of Billing Library 2.0+ #107

Closed befirst closed 3 years ago

befirst commented 3 years ago

https://developer.android.com/google/play/billing/migrate:

Accessing Google Play's billing system using AIDL is deprecated, and all integrations must use the Google Play Billing Library in the future.

https://developer.android.com/google/play/billing/integrate

PeterStaev commented 3 years ago

Hey @befirst , this is already implemented in the plugin available in the ProPlugins NPM registry.

All future work of this plugin will be available exclusively as part of ProPlugins initiative. So if you want to get the latest updates/fixes/features make sure you subscribe to the service. You get all my plugins plus many of the most used and high quality plugins for a small monthly subscription fee.

befirst commented 3 years ago

Hi @PeterStaev. I am writing here because I can't get access to the private repo in GitLab for the paid version.

I have this issue when trying to get a list of products with the paid version of this plugin:

Cannot read property 'querySkuDetailsAsync' of undefined

I have tns version 6.5.0, tns android 6.4.1, plugin version 6.0.0

befirst commented 3 years ago

I tried to update to tns version 7.0.10, and updated tns android to 6.5.3. it doesn't work anyway, the same error.

I tried downgrading the plugin version to 5.0.0, the same. Also after installing the plugin everytime I see a warning that this plugin works with tns anroid version 7, but the last one that is written in official github is 6.5.3

PeterStaev commented 3 years ago

@befirst in the future please open a new issue for your problem, because this has nothing to do with billing lib 2+

Seems your project is not correctly migrated. The latest version of the plugin supports NS 7+. tns-android is depreciated and you should use @nativescript/android instead. Please migrate your project by following https://nativescript.org/blog/nativescript-7-announcement/ and then try again.

befirst commented 3 years ago

Got it, thank you, will try!

befirst commented 3 years ago

Hi again @PeterStaev ! I've tried to update nativescript to the 7th version. I've spent 3days for it. And I haven't success with it, because a lot of libraries that I use doesn't support NS 7+. And all my layouts are broken because of upgrading. Is it possible to install some version of the paid plugin with BillingLibrary 2.0 and with supporting of NS 6?

PeterStaev commented 3 years ago

Hey @befirst , you can use version 4.1 which uses billing lib 2.0 and is NS 6 compatible. But note Billing lib 2 is scheduled to be deprecated sometime next year: Image

befirst commented 3 years ago

Thank you @PeterStaev ! So is it possible to get the third version of the library with NS 6 compatibility? Maybe there is some page where I can get such information just to not ask you about all my problems? But anyway I am changing the purchasing approach because of Warning: AIDL is now deprecated and will be removed in a future release. To implement billing-related features, use the Google Play Billing Library. As I understand it's enough to just change the version of the billing library in the Gradle file just to get the new version? Like that:


dependencies {
    def billing_version = "3.0.0"

    implementation 'com.android.billingclient:billing:$billing_version'
}
befirst commented 3 years ago

@PeterStaev I got the same error anyway( JS: Error getting product details: TypeError: Cannot read property 'querySkuDetailsAsync' of undefined

PeterStaev commented 3 years ago

No, you cannot change the billing library like that, because it comes with breaking changes. The library version is hardcoded in the plugin so that it ensures the plugin works as expected with it. Billing Library 2.x comes with verson 4.1 or lower. Billing Lib 3.x is with 5+ which is only compatible with NS 7.

As for the error - you probably are not using the plugin as described in the readme. Make sure you call init() as described in the readme and as it is in the samples and also make sure you wait the promise that is returned by init to be resolved before calling any other billing related logic.

befirst commented 3 years ago

Thank you @PeterStaev I will check! Btw 2.1.1 version works fine with my project. But anyway I will check the behavior.

befirst commented 3 years ago

Looks like after 2.1.1 the init() call can't finish properly, I don't see any logs that I put in then and in catch. Also, previously it was in the constructor of my service. But pulling out it from there helped to initialize. Interesting...

@PeterStaev thank you very much for your help! Right now it's working, I don't know what I would do without your help!

PeterStaev commented 3 years ago

Glad it is working! 2.x was using still the AIDL so probably that's why it is a diff behavior. 3+ uses the Billing Libs.