我正在遵循一个教程,在一个Ionic应用程序中实现应用程序购买,并收到以下警告:
InAppPurchasejs: load ok:{有效值:[]无效:" productname“,”productname“} store.js DEBUG: ios -> products load store.js DEBUG: state: comionicheathenwws ->无效产品名store.js警告: ios ->产品名称无效(产品名称)
import { Component, OnInit } from '@angular/core';
import { Platform } from '@ionic/angular';
import { InAppPurchase2, IAPProduct } from '@ionic-native/in-app-purchase-2/ngx';
const PRODUCT = 'productname';
const PRODUCT1 = 'productname';
@Component({
selector: 'app-upgrade',
templateUrl: './upgrade.page.html',
styleUrls: ['./upgrade.page.scss'],
})
export class UpgradePage implements OnInit {
products: IAPProduct[] = [];
constructor(public platform: Platform, private store: InAppPurchase2) { }
ngOnInit() {
this.store.verbosity = this.store.DEBUG;
this.registerProducts();
this.setupListeners();
this.products = this.store.products;
console.log('products', JSON.stringify(this.products));
}
registerProducts() {
this.store.register({
id: PRODUCT,
type: this.store.NON_RENEWING_SUBSCRIPTION
});
this.store.register({
id: PRODUCT1,
type: this.store.NON_RENEWING_SUBSCRIPTION
});
this.store.refresh();
}
setupListeners() {
// Register purchase
this.store.when('product')
.registered((product: IAPProduct) => {
if (product.id === PRODUCT) {
console.log('Register PRODUCT');
} else if (product.id === PRODUCT1) {
console.log('Register PRODUCT1');
}
});
// Approved purchase
this.store.when('product')
.approved((product: IAPProduct) => {
if (product.id === PRODUCT) {
console.log('approved PRODUCT');
} else if (product.id === PRODUCT1) {
console.log('approved PRODUCT1');
}
return product.verify();
}).verified((productVerified: IAPProduct) => {
productVerified.finish();
});
// finished purchase
this.store.when('product')
.finished((product: IAPProduct) => {
if (product.id === PRODUCT) {
console.log('finished PRODUCT');
} else if (product.id === PRODUCT1) {
console.log('finished PRODUCT1');
}
});
}
}
我使用的是“cordova-plugin”:"^9.0.0",10.0不起作用。
我在ios模拟器上运行这个应用程序来获取这个错误。
发布于 2021-12-30 05:21:22
你的代码看起来很好。检查您的边界id,以确保它与您在应用程序中使用的id相同。因为这个原因我遇到了这个问题。
https://stackoverflow.com/questions/65119684
复制相似问题