Javascript 在「;应用内购买2“;爱奥尼亚不';归谁所有
我在我的爱奥尼亚项目中使用了应用程序购买2插件,但我有一个国有问题, 交易成功后,产品状态不会返回owned(已处于完成状态) 我需要它来打开when(productId).owned事件 请帮帮我! 这是我的密码:Javascript 在「;应用内购买2“;爱奥尼亚不';归谁所有,javascript,ionic-framework,in-app-purchase,subscription,Javascript,Ionic Framework,In App Purchase,Subscription,我在我的爱奥尼亚项目中使用了应用程序购买2插件,但我有一个国有问题, 交易成功后,产品状态不会返回owned(已处于完成状态) 我需要它来打开when(productId).owned事件 请帮帮我! 这是我的密码: import { Component, ChangeDetectorRef } from "@angular/core"; import {InAppPurchase2, IAPProduct} from "@ionic-native/in-app-p
import { Component, ChangeDetectorRef } from "@angular/core";
import {InAppPurchase2, IAPProduct} from "@ionic-native/in-app-purchase-2/ngx";
import { Platform } from "@ionic/angular";
import { ToastController } from "@ionic/angular";
@Component({
selector: "app-home",
templateUrl: "home.page.html",
styleUrls: ["home.page.scss"],
})
export class HomePage {
duration: any;
isPro: boolean = false;
color: string;
products: IAPProduct[] = [];
constructor(
public platform: Platform,
private iap2: InAppPurchase2,
private toastController: ToastController,
private ref: ChangeDetectorRef
){
this.platform.ready().then(() => {
this.setup();
this.registerHandlersForPurchase("yes_i_am");
this.iap2.ready(() => {
this.products = this.iap2.products;
this.ref.detectChanges();
});
});
}
setup() {
this.iap2.verbosity = this.iap2.DEBUG;
this.iap2.register({
id: "yes_i_am",
type: this.iap2.NON_RENEWING_SUBSCRIPTION,
});
this.iap2.refresh();
}
payment() {
try {
var product = this.iap2.get("yes_i_am");
console.log("Product Info: " + JSON.stringify(product));
this.iap2
.order("yes_i_am")
.then((p) => {
console.log("Purchase Succesful" + JSON.stringify(p));
})
.catch((e) => {
console.log("Error Ordering From Store" + e);
});
} catch (err) {
console.log("Error Ordering " + JSON.stringify(err));
}
}
registerHandlersForPurchase(productId) {
this.iap2.when(productId).updated((p: IAPProduct) => {
if(p.loaded && p.valid && p.state === this.iap2.APPROVED) {
p.finish();
}
this.presentToast(p.owned);
});
this.iap2.validator = "fovea billing";
this.iap2.when(productId).approved((p: IAPProduct) => {
p.verify();
}).verified(function (p: IAPProduct) {
p.finish();
});
this.iap2.when(productId).owned((product: IAPProduct) => {
this.isPro = true;
this.ref.detectChanges();
product.finish();
});
}
restore() {
this.iap2.refresh();
}
async presentToast(message) {
const toast = await this.toastController.create({
message: message,
duration: 4000,
});
toast.present();
}
}
when(productId).owned始终为false,即使我做了任何事情。我的产品是非续费订阅,我在iPhone 6和Xcode上运行它
可能是我弄错了,但我不知道这个。iap2.validator=“fovea账单”代码>注释此行或使用正确的url,因为验证程序的值不正确。