Home > front end >  How to detect owned products with in_app_purchases in Flutter
How to detect owned products with in_app_purchases in Flutter

Time:07-11

I've been following the in_app_purchases package example

I have implemented the in app purchase. A user can buy a product and the listener works to recognize this.

I am getting stuck on how to recognize what the user has purchased in previous sessions. There does not seem to be anything about that in the example/documentation.

Is this what is meant by "restore purchases". I am not sure what does that process refer to? Do I need to restore purchases every time the app starts? Or is there another way to accomplish this?

Help appreciated!

CodePudding user response:

You should keep track of what users purchased yourself. For example on the phone or on a server.

There is plenty of documentation about payment. Apple for example:

https://developer.apple.com/documentation/storekit/in-app_purchase/original_api_for_in-app_purchase/restoring_purchased_products

Users sometimes need to restore purchased content, such as when they upgrade to a new phone. Include some mechanism in your app, such as a Restore Purchases button, to let them restore their purchases.

and …

Don't automatically restore purchases, especially when your app is launched. Restoring purchases prompts for the user’s App Store credentials, which interrupts the flow of your app.

Especially if you are working with subscriptions, you may want to check out »ready to use« solutions like revenue cat for example:

https://pub.dev/packages/purchases_flutter

  • Related