시작하기
설치 단계와 이 플러그인에 대한 전체 마크다운 가이드를 포함한 설정 프롬프트를 복사하세요.
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
‘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
‘disconnect’ 제목현재 계약의 소스 정의를 참조하십시오.
import { MqttBridge } from '@capgo/capacitor-mqtt';
await MqttBridge.disconnect();subscribe
‘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. upstream에서 변경된 경우 pubic API를 다시 동기화하세요.