ページ/エリア: Capgo マーケティング ウェブサイト。役割: ウェブサイト コピー文。見られる場所: component doc/SignupCta.astro, component Hero.astro。メッセージ キー `hero_subtitle_v2` (Hero Subtitle V2)。
このプラグインのインストール手順と完全なマークダウン ガイドを含むセットアップの質問をコピーできます。
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.
Install
Section titled “インストール”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-mqtt` plugin in my project.Manual セットアップを使用する場合は、以下のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の指示に従ってください。
bun add @capgo/capacitor-mqttbunx cap syncimport { MqttBridge } from '@capgo/capacitor-mqtt';API まとめ
API Overviewconnect
接続現在の契約のソース定義を参照してください。
import { MqttBridge } from '@capgo/capacitor-mqtt';
const result = await MqttBridge.connect({ serverURI: 'https://example.com', port: 8080, clientId: 'client-id-123', username: 'username', password: 'password', setCleanSession: true, connectionTimeout: 1000, keepAliveInterval: 1000, setAutomaticReconnect: true,});console.log(result);disconnect
切断現在の契約のソース定義を参照してください。
import { MqttBridge } from '@capgo/capacitor-mqtt';
const result = await MqttBridge.disconnect();console.log(result);subscribe
サブスクライブ現在の契約のソース定義を参照してください。
import { MqttBridge } from '@capgo/capacitor-mqtt';
const result = await MqttBridge.subscribe({ topic: 'topic', qos: 1,});console.log(result);publish
パブリッシュ現在の契約のソース定義を参照してください。
import { MqttBridge } from '@capgo/capacitor-mqtt';
const result = await MqttBridge.publish({ topic: 'topic', payload: 'payload', qos: 1, retained: true,});console.log(result);タイプ リファレンス
タイプ リファレンス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 に対して、Sync を再実行してください。
Getting Started から続けてください。
Section titled “Getting Started から続けてください”。あなたが使用している場合 Getting Started ダッシュボードと API の作業を計画するために使用している場合、 Using @capgo/capacitor-mqtt Using @capgo/capacitor-mqtt Using @API/__CAPGO_KEEP_1__-mqtt APIの実装詳細についての概要です。 Introduction MQTTプラグインの導入 API キー MQTTプラグインの導入の詳細については、API キーを参照してください。 デバイス MQTTプラグインの導入の詳細については、デバイスを参照してください。