Getting Started
このプラグインのインストール手順とフルマークダウンガイドを含むセットアッププロンプトをコピーできます。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-mqtt`
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/mqtt/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.
インストール
Section titled “Install”CapgoのAI-Assisted Setupを使用してプラグインをインストールできます。次のコマンドを使用して、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-mqtt` plugin in my project.Manual Setupを使用する場合は、以下のコマンドを実行してください。プラットフォーム固有の指示に従ってください。
bun add @capgo/capacitor-mqttbunx cap syncImport
Section titled “Import”import { MqttBridge } from '@capgo/capacitor-mqtt';API Overview
API Overviewconnect
接続現在の契約のソース定義を参照してください。
import { MqttBridge } from '@capgo/capacitor-mqtt';
await MqttBridge.connect({} as { serverURI: string; port: number; clientId: string; username: string; password: string; setCleanSession: boolean; connectionTimeout: number; keepAliveInterval: number; setAutomaticReconnect: boolean; setLastWill?: { willTopic: string; willPayload: string; willQoS: number; setRetained: boolean; }; });disconnect
切断現在の契約のソース定義を参照してください。
import { MqttBridge } from '@capgo/capacitor-mqtt';
await MqttBridge.disconnect();subscribe
サブスクライブ現在の契約のソース定義を参照してください。
import { MqttBridge } from '@capgo/capacitor-mqtt';
await MqttBridge.subscribe({} as { topic: string; qos: number });publish
パブリッシュソース定義を参照してください。
import { MqttBridge } from '@capgo/capacitor-mqtt';
await MqttBridge.publish({} as { topic: string; payload: string; qos: number; retained: boolean });型リファレンス
「型リファレンス」onConnectionLostListener
「onConnectionLostListener」export type onConnectionLostListener = (x: { connectionStatus: string; reasonCode: number; message: string }) => void;onConnectCompleteListener
「onConnectCompleteListener」export type onConnectCompleteListener = (x: { reconnected: boolean; serverURI: string }) => void;onMessageArrivedListener
「onMessageArrivedListener」export type onMessageArrivedListener = (x: { topic: string; message: string }) => void;真実の源
「真実の源」このページはプラグインから生成されます。 src/definitions.ts.再度、上流で変更されたパブリックAPIのシンクを実行してください。
Getting Startedから続けてください。
Section titled “Getting Startedから続けてください”。Capgoを使用している場合 Getting Started ダッシュボードとAPIの作業を計画するために、Capgoを使用している場合、Capgoを Using @capgo/capacitor-mqtt Using @capgo/capacitor-mqttのネイティブ機能のために API Overview API Overviewの実装詳細のために Introduction 実装の詳細については、Introductionを参照してください。 API キー 実装の詳細については、API キー、そして デバイス 実装の詳細については、デバイスを参照してください。