Inicio
Copiar una solicitud de configuración con los pasos de instalación y la guía de markdown completa para este complemento.
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.
Instalar
Sección titulada “Instalar”Puede utilizar nuestra configuración asistida por IA para instalar el complemento. Agregue las Capgo habilidades a su herramienta de IA utilizando el siguiente comando:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsLuego utilice la siguiente solicitud:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-share-target` plugin in my project.Si prefiere la configuración manual, instale el complemento ejecutando los siguientes comandos y siguiendo las instrucciones específicas de la plataforma a continuación:
bun add @capgo/capacitor-share-targetbunx cap syncImportar
Sección titulada “Importar”import { CapacitorShareTarget } from '@capgo/capacitor-share-target';API Resumen
Sección titulada “API Resumen”addListener
Sección titulada “Agregar escuchador”Escucha el evento shareReceived.
Registra un oyente que se llamará cuando el contenido se comparta con la aplicación desde otra aplicación. El callback recibe datos de evento que contienen título, textos y archivos.
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
Sección titulada “removeAllListeners”Quitar todos los oyentes para este plugin.
import { CapacitorShareTarget } from '@capgo/capacitor-share-target';
await CapacitorShareTarget.removeAllListeners();getPluginVersion
Sección titulada “getPluginVersion”Obtén la versión nativa Capacitor del plugin.
Devuelve la versión actual de la implementación nativa del plugin.
import { CapacitorShareTarget } from '@capgo/capacitor-share-target';
const { version} = await CapacitorShareTarget.getPluginVersion();console.log('Plugin version:', version);Referencia de tipos
Sección titulada “Type Reference”ShareReceivedEvent
Sección titulada “ShareReceivedEvent”Los datos de evento recibidos cuando el contenido se comparte en la aplicación.
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
Sección titulada “SharedFile”Representa un archivo compartido en la aplicación.
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;}Fuente de Verdad
Sección titulada “Fuente de Verdad”Esta página se genera a partir del plugin’s src/definitions.ts . Re-ejecutar la sincronización cuando el público API cambie en la fuente.
Sigue adelante desde Getting Started
Sección titulada “Sigue adelante desde Getting Started”If you are using Getting Started para planificar la consola y las operaciones de API, conecte con Usando @capgo/capacitor-share-target para la capacidad nativa en Usando @capgo/capacitor-share-target, API Overview para el detalle de implementación en API Overview, Introducción para el detalle de implementación en Introducción, API Keys para el detalle de implementación en API Keys, y Dispositivos para los detalles de implementación en dispositivos.