메인 콘텐츠로 건너뛰기

__CAPGO_KEEP_0__ 저장소 공유 목표

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-share-target` plugin in my project.

만약 Manual Setup을 선호한다면, 플러그인을 설치하기 위해 다음 명령어를 실행하고 아래의 플랫폼별 설명을 따르시오:

터미널 창
bun add @capgo/capacitor-share-target
bunx cap sync
import { CapacitorShareTarget } from '@capgo/capacitor-share-target';

공유 받은 이벤트를 듣는다.

다른 앱에서 애플리케이션으로 콘텐츠를 공유할 때 호출되는 리스너를 등록한다. 이벤트 데이터에는 제목, 텍스트, 파일이 포함된다.

import { CapacitorShareTarget } from '@capgo/capacitor-share-target';
const listener = await CapacitorShareTarget.addListener('shareReceived', (event) => {
console.log('Title:', event.title);
console.log('Texts:', event.texts);
event.files?.forEach(file => {
console.log(`File: ${file.name} (${file.mimeType})`);
});
});
// To remove the listener:
await listener.remove();

removeAllListeners

제목 'removeAllListeners'

이 플러그인의 모든 리스너를 제거합니다.

import { CapacitorShareTarget } from '@capgo/capacitor-share-target';
await CapacitorShareTarget.removeAllListeners();

자연 Capacitor 플러그인의 현재 버전을 반환합니다.

자연 플러그인 구현의 현재 버전을 반환합니다.

import { CapacitorShareTarget } from '@capgo/capacitor-share-target';
const { version} = await CapacitorShareTarget.getPluginVersion();
console.log('Plugin version:', version);

타입 참조

타입 참조

ShareReceivedEvent

공유 받은 이벤트

애플리케이션으로 콘텐츠가 공유될 때 받은 이벤트 데이터입니다.

export interface ShareReceivedEvent {
/**
* The title of the shared content.
*
* @since 0.1.0
*/
title: string;
/**
* Array of text content shared to the application.
*
* @since 0.1.0
*/
texts: string[];
/**
* Array of files shared to the application.
*
* @since 0.2.0
*/
files: SharedFile[];
}

공유된 파일은 애플리케이션에 공유됩니다.

export interface SharedFile {
/**
* The URI of the shared file. On Android/iOS this will be a file path or data URL.
* On web this will be a cached URL accessible via fetch.
*
* @since 0.1.0
*/
uri: string;
/**
* The name of the shared file, with or without extension.
*
* @since 0.1.0
*/
name: string;
/**
* The MIME type of the shared file.
*
* @since 0.1.0
*/
mimeType: string;
}

실제 소스

__CAPGO_KEEP_1__

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

시작부터 계속

__CAPGO_KEEP_2__

__CAPGO_KEEP_3__ __CAPGO_KEEP_4__ 대시보드와 API 운영을 계획하고 연결하세요. Using @capgo/capacitor-share-target Using @capgo/capacitor-share-target API 개요 for the implementation detail in API Overview, 소개 소개 API 키 for the implementation detail in API Keys, and 기기 Devices