__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-auto

Getting Started

GitHub

AI-Assisted セットアップを使用してプラグインをインストールできます。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-auto` plugin in my project.

Manual Setup を使用する場合は、以下のコマンドを実行してください。以下のプラットフォーム固有の指示に従ってください。

  1. パッケージをインストール

    ターミナル画面
    npm i @capgo/capacitor-auto
  2. ネイティブプロジェクトを同期

    ターミナル画面
    npx cap sync
  3. root car テンプレートを設定

    import { Auto } from '@capgo/capacitor-auto';
    await Auto.setRootTemplate({
    title: 'Garage',
    sections: [
    {
    header: 'Doors',
    items: [
    {
    id: 'open-main-door',
    title: 'Open main door',
    subtitle: 'Tap to send the action to the phone app',
    payload: { doorId: 'main' },
    },
    ],
    },
    ],
    });
  4. 車用アクションを処理する

    await Auto.addListener('carAction', async (event) => {
    if (event.id === 'open-main-door') {
    await openGarageDoor(event.payload?.doorId);
    }
    });
  5. 接続状態を追跡する

    const status = await Auto.isAvailable();
    console.log(status.available, status.connected, status.platform);
    await Auto.addListener('connectionChanged', (event) => {
    console.log('Car connected:', event.connected, event.platform);
    });

設定 emptyText テンプレートが行がない場合:

await Auto.setRootTemplate({
title: 'Garage',
emptyText: 'No actions are available right now.',
sections: [],
});

使用 sendMessage アプリ定義のネイティブ橋渡しメッセージのために:

await Auto.sendMessage({
type: 'status',
payload: { online: true },
});

Capgo を使用している場合 Capgo を使用して Capgo を使用して、ネイティブ プラグインの作業を計画するには、Capgo を Capgo に接続します。 Using @capgo/capacitor-auto for the native capability in Using @capgo/capacitor-auto, Capgo Plugin Directory for the product workflow in Capgo Plugin Directory, Capacitor Plugins by Capgo for the implementation detail in Capacitor Plugins by Capgo, プラグインの追加または更新 プラグインの追加または更新の実装詳細について Ionic Enterprise プラグインの代替 Ionic Enterprise プラグインの代替の製品ワークフローについて