已购买的提醒项目未显示,用户可以使用同一帐户再次购买该产品。卸载后他被指控两次。为什么没有显示“已购买商品”的提醒?
我正在使用离子1.x和plugin
这是我使用的代码:
var productIds = ["ch.tapsy.colosseo"];
var spinner = '<ion-spinner icon="dots" class="spinner-stable"></ion-spinner><br/>';
$scope.loadProducts = function() {
console.log("loaded inapp products");
if ($state.current.name === "info") {
$http({
method: "GET",
url: "http://domain.ch/pois.php"
}).then(function mySucces(response) {
console.log("success");
}, function myError(response) {
$scope.errorinapp = "yes";
});
} else {
$http({
method: "GET",
url: "http://domain.ch/pois.php"
}).then(function mySucces(response) {
console.log("success");
}, function myError(response) {
$state.go("inappe")
});
}
$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');
save("isUnlocked", true);
$ionicLoading.hide();
if (state == "l2") {
$state.go("12")
}
if (state == "l1") {
$state.go("11")
}
if (state == "l5") {
$state.go("15")
}
})
.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(purchases);
if (!purchases.length) {
console.log("Sorry, there's nothing to restore. You haven't purchased anything using this account before!");
} else {
localStorage.setItem('sold', 'true');
save("isUnlocked", 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'
});
});
};