j3k0 / cordova-plugin-purchase

In-App Purchase for Cordova on iOS, Android and Windows
https://purchase.cordova.fovea.cc
1.3k stars 537 forks source link

updating ionic (v3) to v10 of plugin (iOS and Android) #987

Closed oofaish closed 4 years ago

oofaish commented 4 years ago

In very short summary, I am using ionic and would like to update to v10 but the node version seems stuck on v8 and the name seems to have changed from cc.fovea.cordova.purchase to cordova-plugin-purchase? Any advice?

system info

ionic v3
cordova-android: "^8.1.0",
cordova-ios: "^5.1.1",

Expected behavior

see v10.0.1 under https://www.npmjs.com/package/cc.fovea.cordova.purchase and so be able to do npm update to update the ionic in app purchase version to v10.0.1 (https://ionicframework.com/docs/v3/native/in-app-purchase-2/)

Observed behavior

the npm package has not been updated and if I try and use the GitHub copy to update it ends up installing a new package with name cordova-plugin-purchase instead of cc.fovea.cordova.purchase. What happens is that the app does not find the plugin (I am assuming due to name changes and so on?) ERROR: Plugin 'InAppPurchase' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml. 2020-02-02 16:30:56.879667+0000 FAILED pluginJSON = ["InAppPurchase...","InAppPurchase","setup",[]]

Steps to reproduce

Just start a new ionic v3 app and try installing the plugin using steps here: https://ionicframework.com/docs/v3/native/in-app-purchase-2/ you end up with v8 rather than v10

distante commented 4 years ago

The ionic docs are outdated, you can install it from : https://www.npmjs.com/package/cordova-plugin-purchase

oofaish commented 4 years ago

but that will involve completely re-writing the code I have written, no? - ionic uses "ionic/native" version of the plugin, which is not the same as this new version which also seems to have had a rename. what am I missing? It's not an easy "switch"

distante commented 4 years ago

I am also using ionic wrapper with the version 10. It works without problems.

oofaish commented 4 years ago

FWIW this is the error on android with "version 8" - I am going to attempt to update to v 10 again

PluginManager: Uncaught exception from plugin
    java.lang.NullPointerException: Attempt to invoke interface method 'android.os.Bundle com.android.vending.billing.IInAppBillingService.getBuyIntent(int, java.lang.String, java.lang.String, java.lang.String, java.lang.String)' on a null object reference
        at com.smartmobilesoftware.util.IabHelper.launchPurchaseFlow(IabHelper.java:444)
        at com.smartmobilesoftware.inappbilling.InAppBillingPlugin.subscribe(InAppBillingPlugin.java:259)
        at com.smartmobilesoftware.inappbilling.InAppBillingPlugin.execute(InAppBillingPlugin.java:111)
        at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:98)
        at org.apache.cordova.PluginManager.exec(PluginManager.java:132)
        at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59)
        at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41)
        at android.os.MessageQueue.nativePollOnce(Native Method)
        at android.os.MessageQueue.next(MessageQueue.java:323)
        at android.os.Looper.loop(Looper.java:136)
        at android.os.HandlerThread.run(HandlerThread.java:61)
oofaish commented 4 years ago

removing platform, removing the old plugin cc.fovea.cordova.purchase and adding the new one seems to have done the trick.