You need to enable JavaScript to run this app. Flutter如何跳转至PlayStore/AppStore的订阅管理页面
优惠活动
大模型
产品
解决方案
定价
更多

Flutter如何跳转至PlayStore/AppStore的订阅管理页面

Flutter 跳转订阅管理页实现方案

In-app Billing API确实不支持在应用内部通过代码直接取消订阅,所有订阅操作需要引导用户到对应平台的官方订阅管理页完成。in_app_purchase包本身未封装跳转逻辑,可配合官方维护的url_launcher包实现,具体实现步骤如下:

  • 第一步:在pubspec.yaml中添加url_launcher依赖
  • 第二步:按平台区分构造订阅页跳转链接,实现跳转逻辑:
    • 安卓平台订阅管理页默认链接格式为https://play.google.com/store/account/subscriptions?package=你的应用包名,可追加&sku=对应订阅商品ID参数直接跳转到指定订阅项
    • iOS平台优先使用原生schemeapp-store://account/subscriptions唤起App Store原生订阅页,低版本兼容可 fallback 到网页链接https://apps.apple.com/account/subscriptions

完整实现代码示例:

import 'package:url_launcher/url_launcher.dart';
import 'dart:io';

Future<void> openSubscriptionManagePage() async {
  Uri targetUri;
  if (Platform.isAndroid) {
    // 替换为自身应用的包名
    const String appPackage = "com.xxx.yourAppName";
    targetUri = Uri.parse("https://play.google.com/store/account/subscriptions?package=$appPackage");
  } else if (Platform.isIOS) {
    targetUri = Uri.parse("app-store://account/subscriptions");
    // 原生scheme跳转失败时用网页链接兜底
    if (!await launchUrl(targetUri)) {
      targetUri = Uri.parse("https://apps.apple.com/account/subscriptions");
    }
  } else {
    // 其他平台可自行扩展逻辑
    return;
  }
  if (await canLaunchUrl(targetUri)) {
    await launchUrl(targetUri, mode: LaunchMode.externalApplication);
  }
}

注意事项

  • 安卓端如果用户已安装谷歌Play商店,会直接唤起商店内的订阅页,未安装时会自动跳转浏览器打开网页版订阅页
  • iOS端app-storescheme为系统白名单允许跳转,无需额外配置Info.plist的跳转白名单
  • 该逻辑完全独立于in_app_purchase的内购交易逻辑,不需要修改现有内购相关代码即可接入

内容的提问来源于stack exchange,提问作者Kanwarpreet Singh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.13 15:12:02