【发布时间】:2015-03-11 05:00:41
【问题描述】:
我正在使用 cordova 在 iOS 商店中制作应用程序,并且我还使用 https://github.com/j3k0/cordova-plugin-purchase/blob/master/doc/api.md 来集成应用内购买。
我已经在我的 iTunes 连接上创建了产品并将代码放在
function initStore(){
if (!window.store) {
log('Store not available');
return;
}
// 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
alert('registerProducts');
store.register({
id: 'com.thegiffary.product.quran_full',
alias: 'full version',
type: store.NON_CONSUMABLE
});
// When any product gets updated, refresh the HTML.
store.when("product").updated(function (p) {
alert(JSON.stringify(p))
});
// When purchase of the full version is approved,
// show some logs and finish the transaction.
store.when("full version").approved(function (order) {
alert('You just unlocked the FULL VERSION!');
order.finish();
});
// The play button can only be accessed when the user
// owns the full version.
store.when("full version").updated(function (product) {
alert(JSON.stringify(product))
});
// When the store is ready (i.e. all products are loaded and in their "final"
// state), we hide the "loading" indicator.
//
// Note that the "ready" function will be called immediately if the store
// is already ready.
store.ready(function() {
alert('ready')
});
// When store is ready, activate the "refresh" button;
store.ready(function() {
alert('refresh-button')
});
// Alternatively, it's technically feasible to have a button that
// is always visible, but shows an alert if the full version isn't
// owned.
// ... but your app may be rejected by Apple if you do it this way.
//
// Here is the pseudo code for illustration purpose.
// myButton.onclick = function() {
// store.ready(function() {
// if (store.get("full version").owned) {
// // access the awesome feature
// }
// else {
// // display an alert
// }
// });
// };
// Refresh the store.
//
// This will contact the server to check all registered products
// validity and ownership status.
//
// It's fine to do this only at application startup, as it could be
// pretty expensive.
alert('refresh');
store.refresh();
}
当我在真机上测试代码时,它返回带有空信息的产品(请看图片)
我不确定我在配置应用内产品时是否遗漏了什么?请给我任何建议。
问候。
【问题讨论】:
-
您能否提供整个代码,因为我正在尝试实现它并进行测试,但无法对其进行正确测试。也让我知道商店验证器的用途。
-
我在标题 desc 等中也得到了空值,但在我正在注册的状态下。请告诉我你是怎么解决的。