yksolanki9 / capacitor-share-with-plugin

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

Home Page:https://npmjs.com/package/capacitor-share-with-plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

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

https://npmjs.com/package/capacitor-share-with-plugin


Languages

Language:JavaScript 31.1%Language:Java 27.1%Language:TypeScript 11.9%Language:Swift 10.2%Language:HTML 8.0%Language:Ruby 6.7%Language:Objective-C 4.7%Language:CSS 0.3%