スタートガイド
インストール手順と、このプラグインの完全なMarkdownガイドを含むセットアッププロンプトをコピーします。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-auto`
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/auto/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-auto` plugin in my project.手動セットアップを希望する場合は、以下のコマンドを実行してプラグインをインストールし、下記のプラットフォーム別の手順に従ってください:
-
パッケージをインストール
ターミナル npm i @capgo/capacitor-auto -
ネイティブプロジェクトを同期
ターミナル npx cap sync -
ルート 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' },},],},],}); -
car アクションの処理
await Auto.addListener('carAction', async (event) => {if (event.id === 'open-main-door') {await openGarageDoor(event.payload?.doorId);}}); -
接続状態の追跡
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);});
クイックスタート
「クイックスタート」セクションimport { Auto } from '@capgo/capacitor-auto';
const result = await Auto.isAvailable();console.log(result);例: setRootTemplate
セクション「Example: setRootTemplate」import { Auto } from '@capgo/capacitor-auto';
await Auto.setRootTemplate({ title: 'Hello from Capacitor', sections: [ { items: [ { id: 'id-123', title: 'Hello from Capacitor', }, ], }, ],});例: setState
セクション「Example: setState」import { Auto } from '@capgo/capacitor-auto';
await Auto.setState({ key: 'key-123', value: {},});よくある落とし穴
「よくある落とし穴」セクション- リスナー: 画面がアンマウントされたらハンドルを削除します。
- ネイティブ同期: 実行
npx cap syncプラグインのアップグレード後。 - 信頼できる情報源: 信頼
src/definitions.tsGitHub リポジトリ内。
設定 emptyText テンプレートに行がない場合:
await Auto.setRootTemplate({ title: 'Garage', emptyText: 'No actions are available right now.', sections: [],});ブリッジメッセージの送信
「Send bridge messages」セクション使用する sendMessage アプリケーション定義のネイティブブリッジメッセージ用:
await Auto.sendMessage({ type: 'status', payload: { online: true },});プラットフォームのセットアップ
「プラットフォームのセットアップ」セクション- 最初のアップデートを送信するには、 iOSの設定 CarPlay シーンとエンタイトルメントに関するメモのページ。
- 最初のアップデートを送信するには、 Androidの設定 Android Autoカテゴリとマニフェストの注意事項ページ。
Getting Startedの続きを進める
「Getting Started からの続き」セクション使用している場合 スタートガイド ネイティブプラグインの作業を計画するには、次と連携してください: @capgo/capacitor-auto の使用方法 @capgo/capacitor-autoの使用におけるネイティブ機能について Capgo プラグインディレクトリ Capgo プラグインディレクトリのプロダクトワークフローについては、 Capgo による Capacitor プラグイン Capgo による Capacitor プラグインの実装詳細については、 プラグインの追加または更新 プラグインの追加または更新における実装詳細については、および Ionic Enterprise プラグインの代替案 Ionic Enterprise プラグインの代替案におけるプロダクトワークフローについては。