0
私は最初のphonegapアプリにhttps://github.com/j3k0/cordova-plugin-purchaseを追加し、このサンプルアプリからコードを試しました:https://github.com/Fovea/cordova-plugin-purchase-demo 私はさまざまな方法で試しましたが、定義されていない "または" if(!windows.store) "に入ります。どうして?phonegap appはcordova-plugin-purchaseで "store is undefined"と言います
// Our application's global object
var app = {};
app.nonHostedContentUrl = "http://ge.tt/api/1/files/3JSfJhL2/0/blob?download";
//
// Constructor
// -----------
//
app.initialize = function() {
//log('initialize');
// Listen to the deviceready event.
// Make sure the score of 'this' isn't lost.
document.addEventListener('deviceready', this.bind(this.onDeviceReady), false);
};
//
// Methods
// -------
//
// deviceready event handler.
//
// will just initialize the Purchase plugin
app.onDeviceReady = function() {
//log('onDeviceReady');
this.initStore();
};
// initialize the purchase plugin if available
app.initStore = function() {
if (!window.store) {
alert('Store not available');
return;
}
app.platform = device.platform.toLowerCase();
//document.getElementsByTagName('body')[0].className = app.platform;
// Enable maximum logging level
store.verbosity = store.DEBUG;
// Enable remote receipt validation
store.validator = "https://api.fovea.cc:1982/check-purchase";
// Inform the store of your products
//log('registerProducts');
store.register({
id: 'consumable1', // id without package name!
alias: 'extra life',
type: store.CONSUMABLE
});
}
// make sure fn will be called with app as 'this'
app.bind = function(fn) {
return function() {
fn.call(app, arguments);
};
};
app.initialize();
私の最初の試みました:
\t function initializeStore() {
\t \t if (!window.store) {
\t \t \t alert('Window.Store not available');
\t \t \t return;
\t \t }
\t \t
\t \t if (!store) {
\t \t \t alert('Store not available');
\t \t \t return;
\t \t }
\t \t
\t \t // Let's set a pretty high verbosity level, so that we see a lot of stuff
\t \t // in the console (reassuring us that something is happening).
\t \t store.verbosity = store.INFO;
\t \t // We register a dummy product. It's ok, it shouldn't
\t \t // prevent the store "ready" event from firing.
\t \t store.register({
\t \t \t id: "myapp.inappid1",
\t \t \t alias: "100 points",
\t \t \t type: store.CONSUMABLE
\t \t });
\t \t store.ready(function() {
\t \t \t alert("\\o/ STORE READY \\o/");
\t \t });
\t \t store.refresh();
\t }
\t
\t document.addEventListener('deviceready', initializeStore, false);
ここで言われように私はまた、プラグインを削除しようとしたし、githubのからそれを追加します。Initialization Android In App Billing using cordova plugin
いくつかの提案?