android ionic应用程序内购买消失
Inapp purchases disappear on android ionic app
我试图用插件cordova-plugin-inapppurchase
实现应用内购买产品加载,但在产品加载后产品不显示。
我错在哪里?
这是我的代码:
<h3 class="inapp_textw" ng-click="loadProducts()" ng-if="!products">Or Inappp purchases</h3>
<h3 class="inapp_textw" ng-repeat="product in products" ng-click="buy(product.productId)">Or Inappp purchases</h3>
JS
var productIds = ["com.domain.example"]; //I have the correct ID
var spinner = '<ion-spinner icon="dots" class="spinner-stable"></ion-spinner><br/>';
$scope.loadProducts = function() {
console.log("loaded inapp products"); // This logs
$ionicLoading.show({
template: spinner + 'Loading...'
});
inAppPurchase
.getProducts(productIds)
.then(function(products) {
$ionicLoading.hide();
$scope.products = products;
})
.catch(function(err) {
$ionicLoading.hide();
console.log(err);
});
};
$scope.buy = function(productId) {
console.log("buy clicked");
$ionicLoading.show({
template: spinner + 'Acquisto in corso...'
});
inAppPurchase
.buy(productId)
.then(function(data) {
console.log(JSON.stringify(data));
console.log('consuming transactionId: ' + data.transactionId);
return inAppPurchase.consume(data.type, data.receipt, data.signature);
})
.then(function() {
localStorage.setItem('sold', 'true');
$ionicLoading.hide();
if (state == "l2") {
$state.go("12")
}
})
.catch(function(err) {
$ionicLoading.hide();
console.log(err);
});
};
$scope.restore = function() {
console.log("IT WORKS");
$ionicLoading.show({
template: spinner + 'Ripristino degli acquisti in corso...'
});
inAppPurchase
.restorePurchases()
.then(function(purchases) {
$ionicLoading.hide();
console.log(JSON.stringify(purchases));
localStorage.setItem('sold', 'true');
$state.go("12")
})
.catch(function(err) {
$ionicLoading.hide();
console.log(err);
$ionicPopup.alert({
title: 'Something went wrong',
template: 'Check your console log for the error details'
});
});
};
你只是在加载产品,这就是为什么它没有显示。
必须打印出来,如下所示。
<h3 class="inapp_textw" ng-repeat="product in products" ng-click="buy(product.productId)">{{product}}</h3>
相关文章:
- facebook”;添加评论“;popup获胜'不要消失
- 无法在Ionic select中预先选择最后一个选项
- 为什么js事件消失了
- JS文件的路径正在消失
- I'我设计了一个下拉菜单,onclick会出现,而on blur会消失
- 如何在Ionic Android中将Javascript注入到web视图中
- Ionic和angularjs嵌套步骤应用程序
- Morris.js折线图x轴标签在调整大小后消失
- 如何在Ionic2测试版中包含Ionic.io服务
- JavaScript下拉菜单-部件在Mac上消失
- 将display属性更改为visible flicks,然后再次消失
- Ionic-item在导航栏中进行双向数据绑定
- TinyMCE实例在切换角度路由选项时会消失
- 将phonegap图像发布到php/mysql-图像字段从发布请求中消失
- SqlStorage Ionic 2作为服务/提供程序
- Ionic V1.3-标签-带条件的徽章样式<离子选项卡>
- 为什么当我尝试在Ionic中使用列表时会出现此JavaScript错误
- using LocalStorage ionic 2
- Jquery UI对话框不会消失
- android ionic应用程序内购买消失