j3k0 / cordova-plugin-purchase

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

Create CdvPurchase... printing twice #1508

Closed bigkingjohn closed 5 months ago

bigkingjohn commented 5 months ago

Observed behavior

I've created an angular app on top of Capacitor that uses your plugin.

After building to my phone from android studio I see the "Create CdvPurchase..." console log twice when I inspect the app in Chrome DevTools.

image

Expected behavior

Is this expected, or have I loaded the plugin incorrectly?

Is this likely to be safe to leave as it is? As far as I can tell, users are able to make purchases, so it looks like it's working.

Other info

This is how I'm using the plugin in my angular code: image

It looks like the plugin's javascript code is being loaded twice.

System Info

I'm using

j3k0 commented 5 months ago

Yes I've seem that issue already. Version 13.10.0 should mitigate this issue (only instantiate if there's no existing instance) until a better solution is found (if you have any idea, fill free to share)

bigkingjohn commented 5 months ago

I don't know much about the capacitor plugin system, but presumably the "correct" instance of the javascript code is the one that is included in the bug chunk of code that Capacitor inserts at the top of the index.html file rather than the one that Angular packages up.

Is it possible to import just a types file in the angular code rather than the whole plugin javascript file? I think this would cause a problem when running the app as a website, I'm not sure if that is important. Would the angular transpiler/compiler raise an error when it discovers the implementation code doesnt exist?

Is this just an Angular problem or does it affect other frameworks like Ionic and React?

More questions than answers I'm afraid.