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.
インストール
「インストール」のセクション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 がアップストリームで変更された場合に、再度同期を実行してください。
Getting Startedから続けて
Getting Startedから続けてというセクション__CAPGO_KEEP_0__を使用している場合 Getting Started APIを使用してダッシュボードとAPIの操作を計画する場合、APIを capgo/capacitor-mqttを使用 Using @capgo/capacitor-mqttのネイティブ機能 APIの概要 APIの実装詳細 Introductionの実装詳細 __CAPGO_KEEP_0__のキー APIのキー APIの実装詳細については、 デバイス __CAPGO_KEEP_0__の実装詳細については、