2.0.9 • Published 3 years ago

capacitor-sharing v2.0.9

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

Capacitor Sharing

Description

Provides a way to share one or more files at a time.

Installation

Capacitor 2

  • npm i capacitor-sharing@1.0.3

Capacitor 3

  • npm i capacitor-sharing

Usage

import { Plugins } from "@capacitor/core";

const { Sharing } = Plugins;

Sharing.share({
  fileNames: ["myImage.jpg", "myDocument.pdf", "myOtherImag.png"],
  base64Values: ["..."],
  contentType: "*/*",
}).then(
  () => {
    //your code
  },
  (error) => {
    console.log(error);
  }
);

Methods

MethodDefaultTypeDescription
share(options: SharingOptions)Promise<any>Prompts the user with sharing options for the provided file(s)

Interfaces

SharingOptions

PropertiesDefaultTypeDescription
fileNamesstring[]Array containing the names of the files.
base64Valuesstring[]Array containing the corresponding bas64 strings of the files.
mimeType?"*/*"stringMIME type of the provided file. Define only when one file is provided.

Android

Gradle

Decalre AndroidX Core Library dependency in your apps build.gradle if not already declared:

dependencies {
  implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
}

or

dependencies {
  implementation "androidx.core:core:$core_version"
}

Manifest

Make sure you have the following provider in your app's Manifest.xml:

<application>
  <provider
    android:name="androidx.core.content.FileProvider"
    android:authorities="${applicationId}.fileprovider"
    android:exported="false"
    android:grantUriPermissions="true">
      <meta-data
          android:name="android.support.FILE_PROVIDER_PATHS"
          android:resource="@xml/file_paths">
        </meta-data>
  </provider>
</application>

File Paths

If you not already created, create an xml folder with a file_paths.xml witht he following content:

<paths xmlns:android="http://schemas.android.com/apk/res/android">
  <files-path
    name="sharing_tmp"
    path="sharing_tmp/"/>
</paths>
2.0.9

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.5

3 years ago

2.0.4

3 years ago

2.0.7

3 years ago

2.0.6

3 years ago

2.0.8

3 years ago

1.0.2

3 years ago

1.0.3

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.1.4

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.1

4 years ago