使用 cordova 插件初始化 Android In App Billing
Initialization Android In App Billing using cordova plugin
在我的 ionic Cordova 应用程序中,我正在使用 In App Purchase 插件:https://github.com/j3k0/cordova-plugin-purchase
这是我用来初始化商店的方法:
storekit.init({
debug: true, // Enable IAP messages on the console
ready: service.IAP.onReady,
purchase: service.IAP.onPurchase,
restore: service.IAP.onRestore,
error: service.IAP.onError
});
此初始化在 iOS 上运行良好,所有产品加载也正常,但 Android 设备在购买时无法加载。
我想,android 有不同的初始化方法。
我在应用中添加了插件:
cordova plugin add cc.fovea.cordova.purchase --variable BILLING_KEY="<BILLING_KEY>"
请帮忙。
首先,当我使用它时,android 上的 npm 版本有点错误。尝试从 Git.
中删除并添加它
cordova plugin add https://github.com/j3k0/cordova-plugin-purchase.git --variable BILLING_KEY="MIIB...AQAB"
其次,您似乎使用了一些较旧的语法。这个插件的 doco 并没有很好的版本控制。网上有不同版本的 doco。我认为 this 是最新版本。
这是我的初始化代码。看看它是否也适合你。
products = ["my.test.product"];
for (var i = 0; i < products.length; i++) {
if (window.store) {
store.register({
id: products[i],
alias: 'alias '+i,
type: store.NON_CONSUMABLE
});
}
}
// When everything goes as expected, it's time to celebrate!
if (window.store) store.ready(function() {
console.log("\o/ STORE READY \o/");
});
// After we've done our setup, we tell the store to do
// it's first refresh. Nothing will happen if we do not call store.refresh()
if (window.store) store.refresh();
您也可以将存储对象发送到 console.log,以便在 chrome 调试器中仔细查看它。
哦,如果您有多个应用程序,请确保您使用的是正确的 BILLING_KEY,方法是删除并阅读插件。
祝你好运!
在我的 ionic Cordova 应用程序中,我正在使用 In App Purchase 插件:https://github.com/j3k0/cordova-plugin-purchase
这是我用来初始化商店的方法:
storekit.init({
debug: true, // Enable IAP messages on the console
ready: service.IAP.onReady,
purchase: service.IAP.onPurchase,
restore: service.IAP.onRestore,
error: service.IAP.onError
});
此初始化在 iOS 上运行良好,所有产品加载也正常,但 Android 设备在购买时无法加载。
我想,android 有不同的初始化方法。
我在应用中添加了插件:
cordova plugin add cc.fovea.cordova.purchase --variable BILLING_KEY="<BILLING_KEY>"
请帮忙。
首先,当我使用它时,android 上的 npm 版本有点错误。尝试从 Git.
中删除并添加它cordova plugin add https://github.com/j3k0/cordova-plugin-purchase.git --variable BILLING_KEY="MIIB...AQAB"
其次,您似乎使用了一些较旧的语法。这个插件的 doco 并没有很好的版本控制。网上有不同版本的 doco。我认为 this 是最新版本。
这是我的初始化代码。看看它是否也适合你。
products = ["my.test.product"];
for (var i = 0; i < products.length; i++) {
if (window.store) {
store.register({
id: products[i],
alias: 'alias '+i,
type: store.NON_CONSUMABLE
});
}
}
// When everything goes as expected, it's time to celebrate!
if (window.store) store.ready(function() {
console.log("\o/ STORE READY \o/");
});
// After we've done our setup, we tell the store to do
// it's first refresh. Nothing will happen if we do not call store.refresh()
if (window.store) store.refresh();
您也可以将存储对象发送到 console.log,以便在 chrome 调试器中仔细查看它。
哦,如果您有多个应用程序,请确保您使用的是正确的 BILLING_KEY,方法是删除并阅读插件。
祝你好运!