简体   繁体   English

Flutter如何实现内购订阅?

[英]How to implement In-App Purchases Subscription in Flutter?

I want to provide auto renewable subscription in my Flutter App for both iOS and Android devices.我想在我的 Flutter 应用程序中为 iOS 和 Android 设备提供自动续订订阅。 Users can subscribe for 1 Month.用户可以订阅 1 个月。

There is not an officially maintained in-app purchase plugin yet.目前还没有官方维护的内购插件。 But there are lots of plugins about In-App Purchases in Flutter.但是Flutter里面有很多关于In-App Purchases的插件。

Which one is the best?哪一个是最好的? How to implement?如何实施? Are these secure?这些安全吗?

==== UPDATE from 11.03.2020 ==== 2020 年 3 月 11 日更新

Hi, I can see this post still reading by people who looking for a method of how to work with subscription in Flutter.嗨,我可以看到这篇文章仍在被那些正在寻找如何在 Flutter 中使用订阅的方法的人阅读。 During 2019 I made two apps with thousands install where users can buy a renewable subscription on the 2 platforms.在 2019 年,我制作了两个安装了数千个的应用程序,用户可以在这两个平台上购买可续订的订阅。 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.直到 2020 年 2 月,我才使用 Flutter 团队https://pub.dev/packages/in_app_purchase 的这个包,但是 - 无法获取有关用户在 iOS 中取消订阅的信息。 This is not the plugin issue, but the iOS approach for the process.这不是插件问题,而是该过程的 iOS 方法。 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).出于安全原因,我们应该实现自己的后端(顺便说一下,Google 也建议这样做,但仍然保留了直接从应用程序检查状态的方式)。

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.因此,经过一些研究,我发现制作后端和插件的人是免费的,直到您当月的收入低于 10 000 美元。 https://www.revenuecat.com/ https://pub.dev/packages/purchases_flutter 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 ==== 2019 年 10 月 3 日更新

I recommend using new package from Flutter team https://pub.dev/packages/in_app_purchase我建议使用 Flutter 团队的新包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代码示例在这里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.通过这个插件,我成功地同时实现了对 Android 和 iOS 的支付和递归订阅。 With the old package I had some minor issues.使用旧包时,我遇到了一些小问题。

You can use nice plugin flutter_inapp_purchase你可以使用不错的插件flutter_inapp_purchase

I've used it for the app that I developed and it works well.我已经将它用于我开发的应用程序,并且运行良好。 You can use my example of how to work with subscription - github There is a complete working example - when you run it, you should get the screen您可以使用我的如何使用订阅的示例 - github有一个完整的工作示例 - 当您运行它时,您应该看到屏幕

在此处输入图片说明

(do not forget to log in to Google play in an emulator or you will get “in-app billing version 3 NOT supported”) (不要忘记在模拟器中登录 Google Play,否则您将获得“不支持应用内结算版本 3”)

For those looking for resource on how to implement IAP, Flutter team wrote a tutorial using in_app_purchase package and Firebase as backend for validation.对于那些寻找有关如何实现 IAP 的资源的人,Flutter 团队编写了一个使用in_app_purchase包和 Firebase 作为验证后端的教程。

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

Android and IOS both with In-App-Purchase with auto-renew working best and easy way in Revenuecat plugin Link https://docs.flutterflow.io/advanced-functionality/payments/revenuecat Android 和 IOS 都具有In-App-Purchase和自动续订功能,在Revenuecat插件链接 https 中效果最佳且简单 链接https://docs.flutterflow.io/advanced-functionality/payments/revenuecat

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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