简体   繁体   中英

Phonegap Plugin not working (cordova-plugin-purchase)

My first Phonegap App. Everything working well except for plugins. I'm trying to install the cordova-plugin-purchase Plugin.

https://github.com/j3k0/cordova-plugin-purchase

I've followed the instructions. And when I run "phonegap plugins" in the console it shows the plugin as being installed.

According to the documentation, there is suppose to be a "store" object that I can reference. I set up the following code to test if it's working:

try {

    store.register({
      id: "my.reverse.item.example",
      alias: "example name",
      type: store.CONSUMABLE
    });

} catch(err) {

    alert(err);

}

On my real project, I have the real info in when registering the product, but I can't even get that far. In my TryCatch it returns the following alert:

"Can't find variable: store".

So it seems that the plugin isn't even installed correct. I'm not to phonegap plugins, so there's probably something very basic that I'm missing. Do I have to include a link to the plugin JS in my index.html file?

I ended up figuring out the problem. It seems to be that I didn't include the cordova.js file in my index.html. I don't see why I needed to do that since I've read over and over that you don't need to manually add the cordova files to your html files.

So the plugin works now and I can receive the store data that I setup using the cordova-plugin-purchase plugin tutorials.

Another thing to note once you actually have the plugin installed correctly: The Bundle Identifier in Xcode needs to match the bundle ID for the In App purchases you are trying to connect to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM