Share APIは、ユーザーがインストールした可能性のある共有対応なアプリでコンテンツを共有するためのメソッドを提供します。
Share APIは、iOS、Android、Webで利用することができます(新しいWeb Share APIを利用しますが、すべてのブラウザで利用できるわけではありません)。
import { Plugins } from '@capacitor/core';
const { Share } = Plugins;
let shareRet = 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.
share(options: ShareOptions) => Promise<any>
Show a Share modal for sharing content in your app with other apps
Param | Type |
---|---|
options |
ShareOptions |
Returns:
Promise<any>
Prop | Type | Description |
---|---|---|
title |
string |
Set a title for any message. This will be the subject if sharing to email |
text |
string |
Set some text to share |
url |
string |
Set a URL to share, can be http, https or file URL |
dialogTitle |
string |
Set a title for the share modal. Android only |