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

Error "store is not defined" Android #325

Closed omaxlive closed 8 years ago

omaxlive commented 9 years ago

I'm using ionic and I get the error "store is not defined" when I run the app on Android device. I already tried reinstalling the plugin but still the same. Any idea what is the problem?

[INFO:CONSOLE(21157)] "ReferenceError: store is not defined

This is the code I'm trying:

store.register({ id: "p02", alias: "premium", type: store.NON_CONSUMABLE }); var p = store.get("p02");

I also tested checking if window.store is available but not. if (!window.store) { console.log('Store not available'); return; }

Installed the plugin using: cordova plugin add cc.fovea.cordova.purchase --variable BILLING_KEY="..."

Config.xml:

AndroidManifest.xml: uses-permission android:name="com.android.vending.BILLING"

My system information: Cordova CLI: 5.3.3 Ionic Version: 1.1.0 Ionic CLI Version: 1.7.7 Ionic App Lib Version: 0.6.3

dkarzon commented 8 years ago

Where are you trying to run that code? Are you waiting for the deviceready event?

document.addEventListener('deviceready', initializeStore, false);
omaxlive commented 8 years ago

Thanks @dkarzon !! It was the problem.