Skip to content

feat: 添加 iOS 快捷指令(App Intents)及 URL Scheme 支持#876

Open
zeke-chin wants to merge 2 commits intoxiaoyaocz:masterfrom
zeke-chin:feature/ios-shortcuts
Open

feat: 添加 iOS 快捷指令(App Intents)及 URL Scheme 支持#876
zeke-chin wants to merge 2 commits intoxiaoyaocz:masterfrom
zeke-chin:feature/ios-shortcuts

Conversation

@zeke-chin
Copy link
Contributor

Summary

  • 添加 iOS App Intents 支持(iOS 16+),使 Simple Live 出现在「快捷指令」App 搜索结果中
  • 注册 simplelive:// URL Scheme(iOS / Android / macOS),支持通过链接唤起 App 跳转直播间
  • 新增使用文档 docs/shortcuts/README.md

iOS 快捷指令(App Intents)

在「快捷指令」App 中搜索 "Simple Live" 即可看到两个原生动作:

动作 参数 说明
打开直播间 直播链接 输入链接,自动解析平台并跳转
跳转直播间 平台 + 房间号 选择平台枚举,填写房间号直接跳转
  • 支持 Siri 语音触发:「用 Simple Live 打开直播间」
  • 使用 @available(iOS 16, *) 守卫,不影响 iOS 13-15 兼容性
  • iOS deployment target 保持不变

URL Scheme

simplelive://open?url=<URL编码后的直播链接>
simplelive://room?site=bilibili&roomId=12345

支持平台:bilibili / douyu / huya / douyin

调用链路

核心逻辑复用了现有的 ParseController.parse() 链接解析和 AppNavigator.toLiveRoomDetail() 房间跳转能力,不涉及重复实现:

App Intents 路径(iOS 16+):

快捷指令 App / Siri
  → AppIntent.perform()
    → AppIntentBridge.sendIntent() [Swift, MethodChannel + 冷启动队列]
      → AppIntentService._handleMethodCall() [Dart]
        → DeepLinkService.handleDeepLinkFromIntent()
          → ParseController.parse() → AppNavigator.toLiveRoomDetail()  (open 动作)
          → AppNavigator.toLiveRoomDetail()                            (room 动作)

URL Scheme 路径(iOS / Android / macOS):

外部调用 simplelive://open?url=... 或 simplelive://room?site=...&roomId=...
  → app_links 插件监听
    → DeepLinkService._handleDeepLink()
      → ParseController.parse() → AppNavigator.toLiveRoomDetail()  (open)
      → AppNavigator.toLiveRoomDetail()                            (room)

变更文件

新增:

  • ios/Runner/AppIntents/ — 5 个 Swift 文件(Bridge、2 个 Intent、枚举、ShortcutsProvider)
  • lib/services/app_intent_service.dart — Dart 侧 MethodChannel 服务
  • lib/services/deep_link_service.dart — 深度链接处理服务
  • docs/shortcuts/README.md — 使用文档

修改:

  • ios/Runner/AppDelegate.swift — 初始化 AppIntentBridge + updateAppShortcutParameters
  • ios/Runner/Info.plist — 注册 simplelive:// URL Scheme
  • android/app/src/main/AndroidManifest.xml — 注册 simplelive:// intent-filter
  • macos/Runner/Info.plist — 注册 simplelive:// URL Scheme
  • lib/main.dart — 注册 DeepLinkService + AppIntentService
  • pubspec.yaml — 添加 app_links 依赖

Test plan

  • macOS 设备测试通过
  • iOS 真机测试通过(快捷指令搜索、App Intents 触发、冷启动跳转)
  • Android 暂未测试

🤖 Generated with Claude Code

zeke-chin and others added 2 commits February 22, 2026 01:53
iOS 快捷指令(App Intents,iOS 16+):
- 打开直播间:输入直播链接,自动解析并跳转
- 跳转直播间:选择平台 + 房间号,直接跳转
- 注册 Siri 短语:「用 Simple Live 打开直播间」
- 使用 @available 守卫,不影响 iOS 13-15 兼容性
- 通过 FlutterMethodChannel 桥接 Swift → Dart,复用 DeepLinkService

simplelive:// URL Scheme(iOS / Android / macOS):
- simplelive://open?url=<链接> — 自动识别平台并跳转
- simplelive://room?site=<平台>&roomId=<房间号> — 直接跳转
- 新增 DeepLinkService 处理深度链接(基于 app_links 插件)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
当前已在直播间时,使用 Get.offNamed() 替换当前路由而非 push,
避免旧直播间资源(播放器、弹幕、定时器)未释放和导航栈堆积。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant