问题
I've a question about in-app purchase subscription. In my app you can create multiple account. this is an example of my problem.
Login paolo.rossi@gmail.com and buy premium,
Logout paolo.rossi@gmail.com
Login paolo.verdi@gmail.com
I've already premium and I can't buy
How to solve this? In many app you can buy premium in the same phone with different account. is it a ionic limitation?
回答1:
I cannot answer how to achieve this in Iconic but this is the general approach I used in Android.
So the idea is to use your own back-end server to do two things:
1: Verify the payment details from your server with the Google. (This prevents hacking apps like Freedom)
2: Use your server to deliver the content and verify expiry.
The approach would be:
- Login paolo.rossi@gmail.com and buy premium (Send payment data to your server and verify with the Google/Apple that the payment is valid and not a fraud. After successful verification, the server sends subscription data like userId and expiry time to the app. The app should store this data in the local storage)
- Logout paolo.rossi@gmail.com.(Remove subscription details from the local storage)
- Login paolo.verdi@gmail.com. (On login send a request to your server "Does this person has a premium subscription?" since Verdi does not have the subscription the server should send a negative response.)
- The app shows you don't have the premium subscription. And Verdi can buy it.
So basically we bound the userId with the subscription and used our own server to verify the subscription.
Hope this helps somebody.
来源:https://stackoverflow.com/questions/54138528/ionic-in-app-purchase-with-multiple-accounts-in-app