简体   繁体   中英

Flutter In app purchase - How allow purchase based on the user that is logged?

I'm building a flutter app that will allow users to subscribe. I'm using this plugin: in_app_purchase 0.5.2

So, my question is: I have to log my users in, and I do this using firebase Auth. But, how can I check which user is logged to deliver them the right purchase? I mean, using the firebase Auth, where or must I check if the current user has purchased something?

You can use a database like firestore to store all the purchase information. Ex: Users/Auth-id

then retrieve it whenever needed. you can also get the previous purchases with the API

Ex:

final QueryPurchaseDetailsResponse response = await InAppPurchaseConnection.instance.queryPastPurchases(); //returns previous purchases 

Note that the App Store does not have any APIs for querying consumable products, and Google Play considers consumable products to no longer be owned once they're marked as consumed and fails to return them here. For restoring these across devices you'll need to persist them on your own server and query that as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM