Skip to content

This plugin allows you to share files from your device's file explorer with your capacitor app.

Notifications You must be signed in to change notification settings

yksolanki9/capacitor-share-with-plugin

Repository files navigation

capacitor-share-with-plugin

NPM Version NPM Downloads

This plugin allows you to share files from the device's file explorer to any capacitor app.

Install

npm install capacitor-share-with-plugin
npx cap sync android

Initial setup

Android

Inside AndroidManifest.xml, in the activity element, add a intent-filter to allow the app to receive images and pdfs from the file explorer and/or other apps.

   <intent-filter>
      <action android:name="android.intent.action.SEND" />
      <action android:name="android.intent.action.SEND_MULTIPLE" />
      <category android:name="android.intent.category.DEFAULT" />
      <data android:mimeType="image/*" />
      <data android:mimeType="application/pdf" />
    </intent-filter>

IOS

This plugin currently supports only Android devices. Support for IOS will be added soon.

API

addListener('FILE_SINGLE', ...)

addListener(eventName: 'FILE_SINGLE', listenerFunc: (event: FileDetails) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param Type Description
eventName 'FILE_SINGLE' Name of the event to listen.
listenerFunc (event: FileDetails) => void Callback to be executed when the event occurs.

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


addListener('FILE_MULTIPLE', ...)

addListener(eventName: 'FILE_MULTIPLE', listenerFunc: (event: FileDetails[]) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param Type Description
eventName 'FILE_MULTIPLE' Name of the event to listen.
listenerFunc (event: FileDetails[]) => void Callback to be executed when the event occurs.

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


Interfaces

PluginListenerHandle

Prop Type
remove () => Promise<void>

FileDetails

Prop Type Description
uri string URI of the file.
ext string Extension of the file.