スタートガイド
インストール手順と、このプラグインの完全なMarkdownガイドを含むセットアッププロンプトをコピーします。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-app-intents`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/app-intents/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
インストール
「インストール」セクションAIアシストによるセットアップでプラグインをインストールできます。以下のコマンドを使用して、お使いのAIツールに Capgo のスキルを追加してください:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins次に、以下のプロンプトを使用します:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-app-intents` plugin in my project.手動でセットアップする場合は、パッケージをインストールしてネイティブプロジェクトをsyncしてください:
npm install @capgo/capacitor-app-intentsnpx cap syncインポート
「インポート」セクションimport { CapgoAppIntents, drainPendingInvocations, useAppIntentsListener,} from '@capgo/capacitor-app-intents';呼び出しの処理(コールドスタート対応)
セクション「呼び出しの処理(コールドスタート対応)」保留キューを処理する前にリスナーを登録してください。これにより、WebView の起動中に発火した Siri、Shortcuts、Spotlight、クイックアクションが失われるのを防げます。
const handleInvocation = async (invocation) => { console.log(invocation.name, invocation.params, invocation.source);};
await useAppIntentsListener(handleInvocation);useAppIntentsListener をアタッチします appIntentInvoked その後、保留中のアイテムを処理します。また、 getPendingInvocations() と removePendingInvocation() 明示的な制御を好む場合は手動で行えます。
Siriフレーズ (codegen)
「Siriフレーズ (codegen)」というセクションAppShortcut フレーズとSF Symbol名は Swiftのコンパイル時リテラル である必要があります。設定は app-shortcuts.config.json アプリのリポジトリで行い、SwiftをiOS アプリ ターゲットに生成します:
node node_modules/@capgo/capacitor-app-intents/scripts/generate-app-shortcuts.mjs \ --config app-shortcuts.config.json \ --output ios/App/App/CapgoGeneratedAppShortcuts.swiftプラグインのSPMパッケージをアプリターゲットにリンクして、 CapgoDispatchAppIntent resolves. Capacitor 8 では、SceneDelegate のクイックアクションと継続中の Spotlight アクティビティを以下で転送します CapgoAppIntentsLifecycle (プラグインのリポジトリを参照) docs/ios-scene-integration.md).
capacitor.config
「capacitor.config」セクションplugins: { CapgoAppIntents: { appGroupId: 'group.your.app', spotlightDomainIdentifier: 'your.app.bundle', },},API の概要
「API 概要」セクションgetPendingInvocations
「getPendingInvocations」セクションJavaScriptの準備ができる前にキューに溜まった呼び出しを返します。
import { CapgoAppIntents } from '@capgo/capacitor-app-intents';
const result = await CapgoAppIntents.getPendingInvocations();console.log(result);removePendingInvocation
「removePendingInvocation」セクションハンドラーでの処理完了後、保留中の呼び出しを1つ削除します。
import { CapgoAppIntents } from '@capgo/capacitor-app-intents';
await CapgoAppIntents.removePendingInvocation({ id: 'id-123' });setEntityCatalog
「setEntityCatalog」セクション指定された型文字列のエンティティカタログを永続化します。
行ごとに新しいSwiftを書くことなく、SiriとShortcutsのエンティティパラメータを駆動します。
import { CapgoAppIntents } from '@capgo/capacitor-app-intents';
await CapgoAppIntents.setEntityCatalog({ type: 'type', entries: [ { id: 'id-123', title: 'Hello from Capacitor', }, ],});setHomeScreenShortcutItems
「setHomeScreenShortcutItems」セクションホーム画面のクイックアクション (UIApplicationShortcutItems) を置き換えます。
import { CapgoAppIntents } from '@capgo/capacitor-app-intents';
await CapgoAppIntents.setHomeScreenShortcutItems({ items: [ { type: 'type', title: 'Hello from Capacitor', }, ],});indexSpotlightEntities
「indexSpotlightEntities」セクションアプリのドメインのSpotlightアイテムをインデックスします。
〜を使用します CSSearchableItem iOS 16以降で利用可能です。iOS 18以降では、ドネーションもサポートされます。
IndexedEntity 値を通じて indexAppEntities と associateAppEntity.
import { CapgoAppIntents } from '@capgo/capacitor-app-intents';
await CapgoAppIntents.indexSpotlightEntities({ entities: [ { id: 'id-123', title: 'Hello from Capacitor', actionName: 'action', }, ],});removeSpotlightEntities
「removeSpotlightEntities」セクションSpotlightの項目をIDで削除します。
import { CapgoAppIntents } from '@capgo/capacitor-app-intents';
await CapgoAppIntents.removeSpotlightEntities({ ids: ['ids'] });performAppleSchemaTemplate
「performAppleSchemaTemplate」セクションアルファ版のAppleスキーマテンプレート用のJavaScriptハンドラーをキューに追加します。
これはプライベートなMailやシステムスキーマAPIを呼び出すものではありません。単に呼び出しを
キューに追加するだけです(例: appleSchemaMailCreateDraft)。これをアプリ code が処理します。
import { CapgoAppIntents } from '@capgo/capacitor-app-intents';
const result = await CapgoAppIntents.performAppleSchemaTemplate({ template: 'mail_create_draft', params: {},});console.log(result);型リファレンス
「型リファレンス」セクションAppIntentInvocation
「AppIntentInvocation」セクションJavaScriptを待機中の保留中のApp Intentスタイルの呼び出し。
export interface AppIntentInvocation { /** * Stable id for this queued invocation. * * @since 0.1.0 */ id: string;
/** * Handler name your JavaScript listens for. * * @since 0.1.0 */ name: string;
/** * Parameters passed from Siri, Shortcuts, Spotlight, or quick actions. * * @since 0.1.0 */ params: Record<string, unknown>;
/** * Origin of the invocation. * * @since 0.1.0 */ source: AppIntentInvocationSource;
/** * Unix timestamp in milliseconds when the invocation was queued. * * @since 0.1.0 */ createdAt: number;}EntityCatalogEntry
「EntityCatalogEntry」セクションSiriとShortcutsのパラメータで使用されるランタイムエンティティカタログの1行。
export interface EntityCatalogEntry { /** * Unique id within the catalog type. * * @since 0.1.0 */ id: string;
/** * Primary label shown in Shortcuts and Siri. * * @since 0.1.0 */ title: string;
/** * Optional subtitle. * * @since 0.1.0 */ subtitle?: string;
/** * Optional extra metadata forwarded to JavaScript when the entity is chosen. * * @since 0.1.0 */ metadata?: Record<string, unknown>;}HomeScreenShortcutItem
「HomeScreenShortcutItem」セクションホーム画面のクイックアクション項目。
export interface HomeScreenShortcutItem { /** * Stable type string delivered to JavaScript. * * @since 0.1.0 */ type: string;
/** * Visible title under the icon. * * @since 0.1.0 */ title: string;
/** * Optional subtitle. * * @since 0.1.0 */ subtitle?: string;
/** * Optional SF Symbol name. * * @since 0.1.0 */ iconName?: string;
/** * Optional params merged into the invocation. * * @since 0.1.0 */ params?: Record<string, unknown>;}SpotlightEntity
セクション「SpotlightEntity」Spotlightで検索可能なエンティティ。
export interface SpotlightEntity { /** * Unique id within your app domain. * * @since 0.1.0 */ id: string;
/** * Title shown in Spotlight. * * @since 0.1.0 */ title: string;
/** * Optional description. * * @since 0.1.0 */ description?: string;
/** * Optional keywords. * * @since 0.1.0 */ keywords?: string[];
/** * Action name delivered when the result is opened. * * @since 0.1.0 */ actionName: string;
/** * Optional params merged into the invocation. * * @since 0.1.0 */ params?: Record<string, unknown>;}AppleSchemaTemplate
「AppleSchemaTemplate」セクションプラグインが提供するアルファ版のApple schema template識別子。
export type AppleSchemaTemplate = 'mail_create_draft';AppIntentInvokedEvent
「AppIntentInvokedEvent」セクションexport interface AppIntentInvokedEvent { /** * The invocation that was just queued or replayed to listeners. * * @since 0.1.0 */ invocation: AppIntentInvocation;}AppIntentInvocationSource
「AppIntentInvocationSource」セクション呼び出しの発生元。
export type AppIntentInvocationSource = 'app_intent' | 'spotlight' | 'quick_action' | 'apple_schema';Source of Truth
「Source Of Truth」セクションこのページはプラグインの src/definitions.tsから生成されています。upstream で公開 API が変更されたら、再度 sync を実行してください。