I’m creating an app it has a subscription option. I used stripe for it but the Apple team won’t allow it. So I’m trying to integrate the in-app purchase option.
I need to fetch all the products from the app store that I have created. then show it to the user, they can buy it.
I got the plugin for it named in-app purchase in ionic documentation. I cant buy the product via the simulator. It says " Cannot connect to iTunes Store".
Problem #1 cant fetch all products dynamically
Problem #2 cant Test it in the simulator
this.iap.getProducts(['first'])
.then((products) => {
console.log(products);
this.products = products;
// [{ productId: 'com.yourapp.prod1', 'title': '...', description: '...', price: '...' }, ...]
})
.catch((err) => {
console.log(err);
});
buyProduct(productId){
this.iap
.buy(productId)
.then((data)=> {
console.log(data);
// {
// transactionId: ...
// receipt: ...
// signature: ...
// }
})
.catch((err)=> {
console.log(err);
});
}
How to test it in the simulator?