Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@capacitor/share
Advanced tools
The Share API provides methods for sharing content in any sharing-enabled apps the user may have installed.
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.
npm install @capacitor/share
npx cap sync
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.
import { Share } from '@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',
});
// Share text only
await Share.share({
text: 'Really awesome thing you need to see right meow',
});
// Share url only
await Share.share({
url: 'http://ionicframework.com/',
});
// Share local file using url parameter
const photo = await Camera.getPhoto(options);
await Share.share({
url: photo.path,
});
// Share multiple files using files parameter
const { photos } = await Camera.pickImages(options);
await Share.share({
files: photos.map(photo => photo.path!),
});
Each platform uses a different set of fields, but you should supply them all.
canShare() => Promise<CanShareResult>
Check if sharing is supported.
Returns: Promise<CanShareResult>
Since: 1.1.0
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
Prop | Type | Description | Since |
---|---|---|---|
value | boolean | Whether sharing is supported or not. | 1.1.0 |
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 |
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 |
files | string[] | Array of file:// URLs of the files to be shared. Only supported on iOS and Android. | 4.1.0 |
dialogTitle | string | Set a title for the share modal. This option is only supported on Android. | 1.0.0 |
FAQs
The Share API provides methods for sharing content in any sharing-enabled apps the user may have installed.
The npm package @capacitor/share receives a total of 29,887 weekly downloads. As such, @capacitor/share popularity was classified as popular.
We found that @capacitor/share demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.