Getting Started
このプラグインのインストール手順と完全なマークダウンガイドを含む設定プロンプトをコピーします。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-share-target`
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/share-target/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.
インストール
「インストール」のセクションCapgoの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-share-target` plugin in my project.Manualセットアップを使用する場合は、以下のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の指示に従ってください。
bun add @capgo/capacitor-share-targetbunx cap syncインポート
セクション「インポート」import { CapacitorShareTarget } from '@capgo/capacitor-share-target';API オーバービュー
セクション「API オーバービュー」addListener
リスナーを追加共有を受信したイベントをリスンする。
このアプリケーションから別のアプリケーションにコンテンツが共有されたときに呼び出されるリスナーを登録します。コールバックは、タイトル、テキスト、ファイルを含むイベントデータを受け取ります。
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
__CAPGO_KEEP_0__ オーバービューコピー
import { CapacitorShareTarget } from '@capgo/capacitor-share-target';
await CapacitorShareTarget.removeAllListeners();getPluginVersion
Section titled “getPluginVersion”ネイティブ Capacitor プラグインのバージョンを取得します。
ネイティブ プラグイン実装の現在のバージョンを返します。
import { CapacitorShareTarget } from '@capgo/capacitor-share-target';
const { version} = await CapacitorShareTarget.getPluginVersion();console.log('Plugin version:', version);タイプ リファレンス
Section titled “Type Reference”ShareReceivedEvent
Section titled “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[];}SharedFile
Section titled “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上流でpublic APIが変更された場合に再度syncを実行してください。
Getting Startedから続けてください
「Getting Startedから続けてください」タイトルCapacitorを使用している場合 Getting Started ダッシュボードとAPIの操作を計画する場合、Capacitorを Capacitorのnative capabilityを使用するには@capgo/capacitor-share-target Capacitorのnative capabilityを使用するには@capgo/capacitor-share-target APIの概要 実装詳細については API の概要を参照してください。 概要 実装詳細については概要を参照してください。 API のキー 実装詳細については API のキー、 デバイス 実装詳細についてはデバイスを参照してください。