概览
“概览”章节@capgo/capacitor-app-intents 将 Apple App Intents 连接到您的 Capacitor JavaScript 层:在冷启动时排空待处理队列、为 Shortcuts 参数发布实体目录、为 Spotlight 内容建立索引、设置主屏幕快速操作,并监听 appIntentInvoked 事件。Siri 快捷指令 短语 是生成的 Swift 代码中的编译期字面量,而非运行时字符串。
将此插件与 Siri、快捷指令与小组件 配合使用,当您同时使用 Widget Kit、Live Activities、Share Target 或 Intent Launcher 时。
平台支持
标题为“平台支持”的部分| 平台 | 支持 | 备注 |
|---|---|---|
| iOS | 是 | iOS 16 及更高版本 |
| Android | 否 | 方法会 reject 并给出明确的错误 |
| Web 端 | 否 | 使用 Capacitor.getPlatform() 做保护 |
核心功能
标题为“核心功能”的章节getPendingInvocations- 返回在 JavaScript 就绪前已排队的调用。removePendingInvocation- 在你的 handler 处理完后,移除一个待处理的调用。setEntityCatalog- 为给定的类型字符串持久化实体目录。setHomeScreenShortcutItems- 替换主屏幕快速操作(UIApplicationShortcutItems)。
公开 API
标题为“公开 API”的章节| 方法 | 描述 |
|---|---|
getPendingInvocations | 返回在 JavaScript 就绪前已排队的调用。 |
removePendingInvocation | 在 handler 处理完后,移除一个待处理的调用。 |
setEntityCatalog | 为给定的类型字符串持久化实体目录。 |
setHomeScreenShortcutItems | 替换主屏幕快速操作 (UIApplicationShortcutItems)。 |
indexSpotlightEntities | 为你的 App 域建立 Spotlight 条目索引。 |
removeSpotlightEntities | 按 id 删除 Spotlight 项。 |
performAppleSchemaTemplate | 将 JavaScript 处理程序加入队列,用于 alpha 版 Apple schema template。 |
addListener | 监听 appIntentInvoked 当有新的调用入队时。 |
removeAllListeners | 移除该插件的所有监听器。 |
getPluginVersion | 原生插件版本字符串。 |
单一事实来源
标题为“单一事实来源”的部分此参考文档同步自 src/definitions.ts 中的 capacitor-app-intents.