我使用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();
}
当我在真实设备上测试代码时,它返回带有空信息的产品(请参见图片)
在配置应用内商品时,我不确定是否会遗漏任何内容?请给我任何建议。
问候。
答案 0 :(得分:0)
我在开发Android应用内购买应用时遇到了类似的问题。我将在黑暗中采取刺,并猜测问题可能类似。我的问题是我的产品的ID与我试图从商店中提取的内容不符。
产品ID和类型必须与Apple和Google开发者控制台中定义的产品相匹配。
在我的情况下,当产品加载时,它具有与您现在获得的字段值相同的字段值。我改变了id,它完全加载了。您可能需要在store.register函数中检查这两个值。