Getting Started
Salin prompt pengaturan dengan langkah instalasi dan panduan markdown lengkap untuk plugin ini.
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.
Instal
Bab berjudul “Instal”Anda dapat menggunakan Pengaturan AI-Assisted untuk menginstal plugin. Tambahkan Capgo kemampuan ke alat AI Anda menggunakan perintah berikut:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsLalu gunakan prompt berikut:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-share-target` plugin in my project.Jika Anda lebih suka Setup Manual, instal plugin dengan menjalankan perintah-perintah berikut dan ikuti instruksi spesifik platform di bawah ini:
bun add @capgo/capacitor-share-targetbunx cap syncImport
Bab berjudul “Import”import { CapacitorShareTarget } from '@capgo/capacitor-share-target';API Ringkasan
Bab berjudul “API Ringkasan”addListener
Bab berjudul “addListener”Listen untuk event shareReceived.
Registrasi seorang pendengar yang akan dipanggil ketika konten dibagikan ke aplikasi dari aplikasi lain. Callback menerima data acara yang berisi judul, teks, dan file.
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
Bab berjudul “removeAllListeners”Hapus semua pendengar untuk plugin ini.
import { CapacitorShareTarget } from '@capgo/capacitor-share-target';
await CapacitorShareTarget.removeAllListeners();getPluginVersion
Bab berjudul “getPluginVersion”Dapatkan versi native Capacitor plugin.
Mengembalikan versi saat ini dari implementasi plugin native.
import { CapacitorShareTarget } from '@capgo/capacitor-share-target';
const { version} = await CapacitorShareTarget.getPluginVersion();console.log('Plugin version:', version);Pengacuan Tipe
Bab berjudul “Type Reference”ShareReceivedEvent
Judul Bagian “ShareReceivedEvent”Data event yang diterima ketika konten dibagikan ke aplikasi.
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
Judul Bagian “SharedFile”Mewakili file yang dibagikan ke aplikasi.
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;}Sumber Kebenaran
Judul Bagian “Sumber Kebenaran”Halaman ini dihasilkan dari plugin’s src/definitions.ts. Re-run sinkronisasi ketika API publik berubah di atas.
Teruskan dari Getting Started
Judul Bagian “Teruskan dari Getting Started”Jika Anda menggunakan Membuat Mulai untuk merencanakan dashboard dan operasi API, hubungkannya dengan Menggunakan @capgo/capacitor-share-target untuk kemampuan asli dalam Menggunakan @capgo/capacitor-share-target, API Ringkasan untuk detail implementasi dalam API Ringkasan, Pendahuluan untuk detail implementasi dalam Pendahuluan, API Kunci untuk detail implementasi dalam API Kunci, dan Perangkat untuk detail implementasi di Perangkat.