내용으로 건너뛰기

시작하기

GitHub

설치

설치

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-mqtt
bunx cap sync

Import

Import
import { MqttBridge } from '@capgo/capacitor-mqtt';

현재 계약의 소스 정의를 참조하십시오.

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;
};
});

현재 계약의 소스 정의를 참조하십시오.

import { MqttBridge } from '@capgo/capacitor-mqtt';
await MqttBridge.disconnect();

현재 계약의 소스 정의를 참조하십시오.

import { MqttBridge } from '@capgo/capacitor-mqtt';
await MqttBridge.subscribe({} as { topic: string; qos: number });

현재 계약의 소스 정의를 참조하세요.

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;
export type onMessageArrivedListener = (x: { topic: string; message: string }) => void;

진실의 근원

Source Of Truth

이 페이지는 플러그인의 src/definitions.ts. 업스트림에서 API이 변경되었을 때 다시 싱크를 실행하세요.

Getting Started

Getting Started

이 플러그인을 사용하여 Getting Started 계획 대시보드 및 API 운영을 계획하고 싶다면 Using @capgo/capacitor-mqtt Using @capgo/capacitor-mqtt for the native capability in Using @API/__CAPGO_KEEP_1__-mqtt, for the implementation detail in API Overview, 소개 소개에 대한 구현 세부 정보를 위해 API 키 API 키에 대한 구현 세부 정보를 위해, 및 장치 장치에 대한 구현 세부 정보를 위해