Android Ionic 3-使用Inapppurchase2插件进行应用内购买,无响应
我已经安装了插件实现了代码。。上传已签名的apk作为内部测试人员,但当我单击“购买”按钮时,什么也没有发生。。谁能告诉我哪里出了问题Android Ionic 3-使用Inapppurchase2插件进行应用内购买,无响应,android,ionic-framework,ionic3,in-app-purchase,cordova-plugins,Android,Ionic Framework,Ionic3,In App Purchase,Cordova Plugins,我已经安装了插件实现了代码。。上传已签名的apk作为内部测试人员,但当我单击“购买”按钮时,什么也没有发生。。谁能告诉我哪里出了问题 import { Component, OnInit } from '@angular/core'; import { NewTransactionPage } from '../instamojo/new_transaction'; import { IonicPage, Platform, NavController, NavParams } from 'io
import { Component, OnInit } from '@angular/core';
import { NewTransactionPage } from '../instamojo/new_transaction';
import { IonicPage, Platform, NavController, NavParams } from 'ionic-angular';
import { InAppPurchase2, IAPProduct } from '@ionic-native/in-app-purchase-2/ngx';
@IonicPage()
@Component({
selector: 'page-pay',
templateUrl: 'pay.html',
})
export class PayPage {
public product: any = {
name: 'Upgrade to Pro',
appleProductId: 'android.test.purchased',
googleProductId: 'ultimate'
};
constructor(
public navCtrl: NavController,
public navParams: NavParams,
public platform: Platform,
public store: InAppPurchase2
) {
platform.ready().then(() => {
this.configurePurchasing();
});
}
configurePurchasing() {
if (!this.platform.is('cordova')) { return; }
let productId;
try {
if (this.platform.is('ios')) {
productId = this.product.appleProductId;
} else if (this.platform.is('android')) {
productId = this.product.googleProductId;
}
// Register Product
// Set Debug High
this.store.verbosity = this.store.DEBUG;
// Register the product with the store
this.store.register({
id: productId,
alias: productId,
type: this.store.NON_CONSUMABLE
});
this.registerHandlers(productId);
InAppPurchase2.getPlugin().ready().then((status) => {
console.log(JSON.stringify(this.store.get(productId)));
console.log('Store is Ready: ' + JSON.stringify(status));
console.log('Products: ' + JSON.stringify(this.store.products));
});
// Errors On The Specific Product
this.store.when(productId).error( (error) => {
alert('An Error Occured' + JSON.stringify(error));
});
// Refresh Always
console.log('Refresh Store');
this.store.refresh();
} catch (err) {
console.log('Error On Store Issues' + JSON.stringify(err));
}
}
registerHandlers(productId) {
// Handlers
this.store.when(productId).approved( (product: IAPProduct) => {
// Purchase was approved
product.finish();
});
this.store.when(productId).registered( (product: IAPProduct) => {
console.log('Registered: ' + JSON.stringify(product));
});
this.store.when(productId).updated( (product: IAPProduct) => {
console.log('Loaded' + JSON.stringify(product));
});
this.store.when(productId).cancelled( (product) => {
alert('Purchase was Cancelled');
});
// Overall Store Error
this.store.error( (err) => {
alert('Store Error ' + JSON.stringify(err));
});
}
async purchase() {
/* Only configuring purchase when you want to buy, because when you configure a purchase
It prompts the user to input their apple id info on config which is annoying */
if (!this.platform.is('cordova')) { return };
let productId;
if (this.platform.is('ios')) {
productId = this.product.appleProductId;
} else if (this.platform.is('android')) {
productId = this.product.googleProductId;
}
console.log('Products: ' + JSON.stringify(this.store.products));
console.log('Ordering From Store: ' + productId);
try {
let product = this.store.get(productId);
console.log('Product Info: ' + JSON.stringify(product));
let order = this.store.order(productId);
alert('Finished Purchase');
} catch (err) {
console.log('Error Ordering ' + JSON.stringify(err));
}
}
backHomePage() {
this.navCtrl.pop();
}
}
我曾尝试在没有--prod的情况下构建应用程序,但仍然无法运行。我正在调用purchase()函数,但什么也没发生您找到什么了吗?我有完全相同的问题。是的。作为一个白痴,我在爱奥尼亚3项目上使用了爱奥尼亚4应用内购买NPM软件包我在使用爱奥尼亚4和爱奥尼亚4 NPM软件包,但我仍然有完全相同的问题。嗯。。我必须看一下你的代码才能理解问题你能看一下我的代码吗?你能分享一些联系方式吗?你找到什么了吗?我有完全相同的问题。是的。作为一个白痴,我在爱奥尼亚3项目上使用了爱奥尼亚4应用内购买NPM软件包我在使用爱奥尼亚4和爱奥尼亚4 NPM软件包,但我仍然有完全相同的问题。嗯。。我必须看一下你的代码才能理解问题你能看一下我的代码吗?你能分享一些联系方式吗?