メインコンテンツへスキップ
@capgo/capacitor-app-intents UI & システム オープンソース

App Intents Capacitor プラグイン

Capacitor を使えば、アクションごとに Web レイヤーを再ビルドすることなく、Siri のフレーズ、ショートカット、Spotlight、ホーム画面のクイックアクション、App Intents エンティティカタログを配信できます

インストール

bun add @capgo/capacitor-app-intents bunx cap sync
npm、pnpm、または yarn
  • npm install @capgo/capacitor-app-intents
  • pnpm add @capgo/capacitor-app-intents
  • yarn add @capgo/capacitor-app-intents

ガイド

Capacitor で App Intents を使う方法

@capgo/capacitor-app-intents の使用

Capgo App Intents プラグインのインターフェース。

インストール

bun add @capgo/capacitor-app-intents
bunx cap sync

bunx cap sync プラグインのネイティブcodeをネイティブプロジェクトにコピーします。プラグインをアップグレードするたびに再度実行してください。

インポート

import { CapgoAppIntents } from '@capgo/capacitor-app-intents';

API の概要

メソッド 説明
getPendingInvocations JavaScriptの準備ができる前にキューに溜まった呼び出しを返します。
removePendingInvocation ハンドラーでの処理完了後、保留中の呼び出しを1つ削除します。
setEntityCatalog 指定された型文字列のエンティティカタログを永続化します。
setHomeScreenShortcutItems ホーム画面のクイックアクション (UIApplicationShortcutItems) を置き換えます。
indexSpotlightEntities アプリのドメインのSpotlightアイテムをインデックスします。
removeSpotlightEntities Spotlightの項目をIDで削除します。
performAppleSchemaTemplate アルファ版のAppleスキーマテンプレート用のJavaScriptハンドラーをキューに追加します。

例

getPendingInvocations()

JavaScriptの準備ができる前にキューに溜まった呼び出しを返します。

import { CapgoAppIntents } from '@capgo/capacitor-app-intents';

const result = await CapgoAppIntents.getPendingInvocations();
console.log(result);

removePendingInvocation()

ハンドラーでの処理完了後、保留中の呼び出しを1つ削除します。

import { CapgoAppIntents } from '@capgo/capacitor-app-intents';

await CapgoAppIntents.removePendingInvocation({ id: 'id-123' });

setEntityCatalog()

指定された型文字列のエンティティカタログを永続化します。

import { CapgoAppIntents } from '@capgo/capacitor-app-intents';

await CapgoAppIntents.setEntityCatalog({
  type: 'type',
  entries: [
    {
      id: 'id-123',
      title: 'Hello from Capacitor',
    },
  ],
});

setHomeScreenShortcutItems()

ホーム画面のクイックアクション (UIApplicationShortcutItems) を置き換えます。

import { CapgoAppIntents } from '@capgo/capacitor-app-intents';

await CapgoAppIntents.setHomeScreenShortcutItems({
  items: [
    {
      type: 'type',
      title: 'Hello from Capacitor',
    },
  ],
});

indexSpotlightEntities()

アプリのドメインのSpotlightアイテムをインデックスします。

import { CapgoAppIntents } from '@capgo/capacitor-app-intents';

await CapgoAppIntents.indexSpotlightEntities({
  entities: [
    {
      id: 'id-123',
      title: 'Hello from Capacitor',
      actionName: 'action',
    },
  ],
});

removeSpotlightEntities()

Spotlightの項目をIDで削除します。

import { CapgoAppIntents } from '@capgo/capacitor-app-intents';

await CapgoAppIntents.removeSpotlightEntities({ ids: ['ids'] });

上記の表には7つの主要なメソッドが記載されています。リスナーやバージョンのヘルパー、および各メソッドの詳細な仕様については、 GitHub リポジトリ.

イベントをリッスンする

addListener ハンドルを返します。画面がアンマウントされるときに handle.remove() 画面がアンマウントされるとき、または CapgoAppIntents.removeAllListeners() すべてのリスナーを解除します。

完全なリファレンス

よくある質問

App Intents プラグイン FAQ

Capacitor アプリに App Intents プラグインをインストールするにはどうすればよいですか?

"bun add @capgo/capacitor-app-intents"(または "npm install @capgo/capacitor-app-intents")を実行し、続けて "bunx cap sync" を実行すると、iOS と Android のプロジェクトにネイティブの code が反映されます。アプリの code 内で "@capgo/capacitor-app-intents" からインポートしてください。

@capgo/capacitor-app-intents は React、Vue、Angular で動作しますか?

はい。App Intents は Capacitor パッケージなので、Ionic、React、Vue、Angular、Svelte、素の JavaScript など、Capacitor 上で動くあらゆる Web フレームワークで使えます。

@capgo/capacitor-app-intents はどの Capacitor バージョンをサポートしていますか?

Capgo プラグインは Capacitor のメジャーバージョンに合わせています。使用している Capacitor のメジャーバージョンに一致するプラグインのメジャーバージョンを使ってください (例: Capacitor 8 ならプラグイン v8)。GitHub の README にある互換性テーブルに、メンテナンス中のバージョンが記載されています。

@capgo/capacitor-app-intents は無料でオープンソースですか?

はい。code のソースコードは GitHub の https://github.com/Cap-go/capacitor-app-intents/ で公開されており、パッケージは npm から無料でインストールできます。バグ報告やプルリクエストも歓迎です。

App Intents を使っている code を App Store の審査なしでアップデートできますか?

プラグインのインストールやアップグレードはネイティブの code を変更するため、新しいストアビルドが必要です。その後は、プラグインを呼び出す JavaScript、HTML、CSS の変更を Capgo Live Updates で即座に配信できます。

アプリの審査を待たずに App Intents の変更をリリース

プラグインをストア用ビルドに組み込めば、Capgo live updates で JavaScript、HTML、CSS の変更を数分でユーザーに配信できます

Capgo から始める