I have a more or less complex question:
I have an InAppPurchase subscription in my app, therefor iam using the ionic native InAppPurchase Plugin:
The subscription is auto renewal and have a test time of 7 days.
The purchase itself works very well:
buyProduct(productName: string): void {
console.log(productName);
InAppPurchase
.getProducts([productName])
.then((products) => {
InAppPurchase
.buy(productName)
.then((data)=> {
// do something here: maybe store somethign to firebase? But what?
})
.catch((err)=> {
console.log("error buy");
console.log(JSON.stringify(err));
});
})
.catch((err) => {
console.log("error getProducts");
console.log(JSON.stringify(err));
});
}
I have a 2 qustions:
1: How do i check if the subscription is still active?
On App start i want to know, if the subscription is active.
I thinks its easy on Android: there is the function “restorePurchases()”, where you will get a state with “0 - ACTIVE, 1 - CANCELLED, 2 - REFUNDED”.
On IOS i have to save the reciepe somehow, but how? Does someone you have any code examples here?
2: I want to save the current subscription status to firebase.
Whats the best way to do this? Which data should i save?