Flutter 应用内购买非续订订阅

时间:2021-06-28 07:52:28

标签: flutter in-app-purchase in-app-billing

我想制作一个定期通行证项目(例如:1 周通行证、1 个月通行证),以便为用户移除广告和访问优质内容。

我看到 Android 有 // typedef ItemValueWidgetBuilder<T> = Widget Function(BuildContext context, T key, bool active); class SegmentedSlider<T> extends StatefulWidget { final Color backgroundColor; final Color thumbColor; final ValueChanged<T?> onValueChanged; final T selectedValue; final List<T> values; final ItemValueWidgetBuilder<T> itemBuilder; const SegmentedSlider({Key? key, this.thumbColor = Colors.grey, this.backgroundColor = Colors.white, required this.onValueChanged, required this.itemBuilder, required this.selectedValue, required this.values}) : super(key: key); @override _SegmentedSliderState<T> createState() => new _SegmentedSliderState<T>(); } class _SegmentedSliderState<T> extends State<SegmentedSlider> { late T activeValue; @override void initState() { // TODO: implement initState super.initState(); activeValue = widget.selectedValue; } @override Widget build(BuildContext context) { var map = widget.values.map((e) { var _widget = widget.itemBuilder(context, e, e == activeValue); print(_widget); return MapEntry<T, Widget>(e, _widget); }); Map<T, Widget> children = Map.fromEntries(map); return CupertinoSlidingSegmentedControl<T>( backgroundColor: widget.backgroundColor, thumbColor: widget.thumbColor, onValueChanged: (value) { activeValue = value!; widget.onValueChanged(value); }, children: children, groupValue: widget.selectedValue, ); } } consumablenon-consumable
而IOS有subscriptionconsumablenon-consumableauto-renewable-subscription
但是在 Flutter 的 In-App-Purchase 中,只有两个选项:non-renewable-subscriptionconsumable

如何使用 In-App-Purchase 在 Android 和 IOS 中实现此应用程序的 Flutter 应用程序?

1 个答案:

答案 0 :(得分:0)

您必须为其创建自定义逻辑才能正常工作。我会建议您使用 cron 包来使 android 端工作管理器上的周期性任务是最好的,但它不适用于 ios 端,但 cron 可以。或者,您可以使用 firebase 计划功能完成工作,但这是一种糟糕的方法,最好的方法是在应用程序购买中使用带有颤振的 cron 我也通过 ios 端完成了类似的任务。