はじめから始める
このプラグインのインストール手順と全てのマークダウン ガイドを含むセットアップ コマンドをコピーしてください。
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.
インストール
「インストール」のセクションCapgo の 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-mqtt` plugin in my project.Manual Setupを使用する場合は、以下のコマンドを実行してプラグインをインストールし、下記のプラットフォーム固有の説明を参照してください:
bun add @capgo/capacitor-mqttbunx cap syncインポート
セクション「インポート」import { MqttBridge } from '@capgo/capacitor-mqtt';APIの概要
セクション「APIの概要」connect
接続現在の契約のソース定義を参照してください。
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
接続失敗リスナーexport type onConnectionLostListener = (x: { connectionStatus: string; reasonCode: number; message: string }) => void;onConnectCompleteListener
接続完了リスナーexport type onConnectCompleteListener = (x: { reconnected: boolean; serverURI: string }) => void;onMessageArrivedListener
メッセージ到着リスナーexport type onMessageArrivedListener = (x: { topic: string; message: string }) => void;真実の源
真実の源このページはプラグインから生成されています。 src/definitions.tsパブリック API がアップストリームで変更された場合に、再度同期を実行してください。
はじめから始める
はじめから始めるセクションCapgoを使用している場合 はじめから始める ダッシュボードとAPIの作業を計画するには、APIを Capgoのcapgo/capacitor-mqtt Capgoのcapgo/capacitor-mqttのネイティブ機能 APIの概要 APIの実装詳細 導入 __CAPGO_KEEP_0__のキー API 実装詳細については API キーを参照してください。 デバイス 実装詳細についてはデバイスを参照してください。