Inizia
Copia un prompt di configurazione con i passaggi di installazione e la guida markdown completa per questo plugin.
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.
bun add @capgo/capacitor-share-targetbunx cap syncimport { CapacitorShareTarget } from '@capgo/capacitor-share-target';API Panoramica
Sottosezione intitolata “API Panoramica”addListener
Sottosezione intitolata “addListener”Ascolta l'evento shareReceived.
Registra un ascoltatore che verrà chiamato quando il contenuto viene condiviso nell'applicazione da un'altra app. Il callback riceve i dati dell'evento contenenti titolo, testi e 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
Sezione intitolata “removeAllListeners”Rimuovi tutti gli ascoltatori per questo plugin.
import { CapacitorShareTarget } from '@capgo/capacitor-share-target';
await CapacitorShareTarget.removeAllListeners();getPluginVersion
Sezione intitolata “getPluginVersion”Ottieni la versione nativa Capacitor del plugin.
Restituisce la versione corrente dell'implementazione del plugin nativo.
import { CapacitorShareTarget } from '@capgo/capacitor-share-target';
const { version} = await CapacitorShareTarget.getPluginVersion();console.log('Plugin version:', version);Riferimento di tipo
Sezione intitolata “Type Reference”ShareReceivedEvent
Sezione intitolata “ShareReceivedEvent”I dati dell'evento ricevuti quando il contenuto viene condiviso con l'applicazione.
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
Sezione intitolata “SharedFile”Rappresenta un file condiviso con l'applicazione.
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;}Fonte di Verità
Sezione intitolata “Fonte di Verità”Questa pagina è generata dal plugin e viene sincronizzata con il suo repository remoto. Re-run la sincronizzazione quando le modifiche pubbliche __CAPGO_KEEP_0__ vengono apportate al repository remoto. src/definitions.ts. Re-run the sync when the public API changes upstream.