npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

romone183-capacitor-share

v1.0.0

Published

Improved Capacitor Share Plugin. Handle sharing both file and text with WhatsApp.

Downloads

4

Readme

romone183-capacitor-share

This plugin handles sharing both file and text via WhatsApp on iOS.

The Share API provides methods for sharing content in any sharing-enabled apps the user may have installed.

The Share API works on iOS, Android, and the Web (using the new Web Share API), though web support is currently spotty.

Install

npm install romone183-capacitor-share
npx cap sync

Android

By default, Capacitor apps only allow to share files from caches folder. To make other Android folders shareable, they have to be added in android/app/src/main/res/xml/file_paths.xml file. Check the Specifying Available Files section in FileProvider docs for the available locations.

Example

import { Share } from 'romone183-capacitor-share';

await Share.share({
  title: 'See cool stuff',
  text: 'Really awesome thing you need to see right meow',
  url: 'http://ionicframework.com/',
  dialogTitle: 'Share with buddies',
});

Each platform uses a different set of fields, but you should supply them all.

Configuration

These config values are available:

| Prop | Type | Description | Since | | ---------------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- | | whatsAppStep1Msg | string | Set an alert for WhatsApp when you have image and text to share at the same time. This is not possible with WhatsApp, only image will be display when you have to share both. After sharing the image, Share component will be call again to share text This message will be displayed on the step 1 as an alert. Share the file This option is only supported on iOS. | 1.0.0 | | whatsAppStep2Msg | string | Set an alert for WhatsApp when you have image and text to share at the same time. This message will be displayed on the step 2 as an alert. Share the text Only available on iOS. | 1.0.0 |

Examples

In capacitor.config.json:

{
  "plugins": {
    "Share": {
      "whatsAppStep1Msg": "WhatsApp can't share both File and Text. Step 1: Share File",
      "whatsAppStep2Msg": "Step 2: Share Text"
    }
  }
}

In capacitor.config.ts:

/// <reference types="@capacitor/share" />

import { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  plugins: {
    Share: {
      whatsAppStep1Msg: "WhatsApp can't share both File and Text. Step 1: Share File",
      whatsAppStep2Msg: "Step 2: Share Text",
    },
  },
};

export default config;

API

canShare()

canShare() => Promise<CanShareResult>

Check if sharing is supported.

Returns: Promise<CanShareResult>

Since: 1.0.0


share(...)

share(options: ShareOptions) => Promise<ShareResult>

Show a Share modal for sharing content with other apps

| Param | Type | | ------------- | ----------------------------------------------------- | | options | ShareOptions |

Returns: Promise<ShareResult>

Since: 1.0.0


Interfaces

CanShareResult

| Prop | Type | Description | Since | | ----------- | -------------------- | ------------------------------------ | ----- | | value | boolean | Whether sharing is supported or not. | 1.0.0 |

ShareResult

| Prop | Type | Description | Since | | ------------------ | ------------------- | ------------------------------------------------------------------------------------------------------------------------ | ----- | | activityType | string | Identifier of the app that received the share action. Can be an empty string in some cases. On web it will be undefined. | 1.0.0 |

ShareOptions

| Prop | Type | Description | Since | | ----------------- | ------------------- | -------------------------------------------------------------------------- | ----- | | title | string | Set a title for any message. This will be the subject if sharing to email | 1.0.0 | | text | string | Set some text to share | 1.0.0 | | url | string | Set a URL to share, can be http, https or file:// URL | 1.0.0 | | dialogTitle | string | Set a title for the share modal. This option is only supported on Android. | 1.0.0 |