0.1.1 • Published 2 years ago

capacitor-share-with-plugin v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

capacitor-share-with-plugin

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
ParamTypeDescription
eventName'FILE_SINGLE'Name of the event to listen.
listenerFunc(event: FileDetails) => voidCallback 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
ParamTypeDescription
eventName'FILE_MULTIPLE'Name of the event to listen.
listenerFunc(event: FileDetails[]) => voidCallback to be executed when the event occurs.

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


Interfaces

PluginListenerHandle

PropType
remove() => Promise<void>

FileDetails

PropTypeDescription
uristringURI of the file.
extstringExtension of the file.