如何在Flutter中实现应用内购买订阅?

How to implement In-App Purchases Subscription in Flutter?

我想在我的 Flutter 应用程序中为 iOS 和 Android 设备提供自动续订订阅。用户可以订阅 1 个月。

暂无官方维护的内购插件。但是 Flutter 中有很多关于 In-App Purchases 的插件。

哪个最好?如何实施?这些安全吗?

==== UPDATE from 11.03.2020

Hi, I can see this post still reading by people who looking for a method of how to work with subscription in Flutter. During 2019 I made two apps with thousands install where users can buy a renewable subscription on the 2 platforms. Until February 2020 I used for this package from Flutter team https://pub.dev/packages/in_app_purchase, BUT - there is no way to get info about the user to unsubscribe in iOS. This is not the plugin issue, but the iOS approach for the process. We should implement our own backend for security reasons (by the way Google also recommends to do the same, but still left the way to check the state directly from the app).

So, after some researches, I found guys who made backend and plugin and it is free until you have less than 10 000 USD revenue for the month. https://www.revenuecat.com/ https://pub.dev/packages/purchases_flutter

I've implemented this plugin in my apps and it works like a charm. There is some good approaches that allow you to get a subscription state at any point in the app. I'm going to make an example and article, but not sure about the timing.

==== UPDATE from 03.10.2019

I recommend using new package from Flutter team https://pub.dev/packages/in_app_purchase

The example with code is here https://github.com/flutter/plugins/tree/master/packages/in_app_purchase/in_app_purchase/example

With this plugin I successfully implemented payments and recursive subscriptions to Android and iOS simultaneously. With the old package I had some minor issues.

你可以使用不错的插件flutter_inapp_purchase

我已经将它用于我开发的应用程序并且运行良好。您可以使用我关于如何使用订阅的示例 - github 有一个完整的工作示例 - 当你 运行 它时,你应该得到屏幕

(不要忘记登录 Google 在模拟器中玩,否则你会得到“不支持应用内结算版本 3”)

对于那些寻找有关如何实施 IAP 的资源的人,Flutter 团队编写了一个使用 in_app_purchase 包和 Firebase 作为验证后端的教程。

Link: https://codelabs.developers.google.com/codelabs/flutter-in-app-purchases#0