메뉴로 바로가기

시작하기

설치

설치란
터미널 창
bun add @capgo/capacitor-share-target
bunx cap sync

import

import란
import { CapacitorShareTarget } from '@capgo/capacitor-share-target';

API 개요

API란

공유 받은 이벤트를 듣습니다.

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

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

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

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

진실의 근원

진실의 근원

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