# Cordova Social Sharing プラグイン

この Cordova プラグインでは、ソーシャルネットワーク、SMS、電子メール経由のテキスト、ファイル、画像、リンクを共有を行います。

* Repo: <https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin>
* Plugin ID/Package Name: `cordova-plugin-x-socialsharing`
* Tested Version: `6.0.4`
* Repo: <https://github.com/EddyVerbruggen/cordova-plugin-actionsheet>
* Plugin ID/Package Name: `cordova-plugin-actionsheet`
* Tested Version: `2.3.3`

{% hint style="info" %}
サードパーティー製 Cordova プラグインを確認する場合は、カスタムビルドデバッガー ( [Android 版](https://ja.docs.monaca.io/products_guide/debugger/installation/debugger_android#kasutamubirudo-monaca-debaggnobirudotoinsutru) または [iOS 版](https://ja.docs.monaca.io/products_guide/debugger/installation/debugger_ios#kasutamubirudo-monaca-debaggnobirudo) ) を作成する必要があります。

Android カスタムビルドデバッガーを使用する場合は、[ cordova-plugin-androidx-adapter ](https://github.com/dpa99c/cordova-plugin-androidx-adapter)をインポートするをインポートする必要があります。
{% endhint %}

## デモ

[<img src="https://docs.monaca.io/images/common/import_img.png" alt="" data-size="line">プロジェクトをインポート](https://monaca.mobi/ja/directimport?pid=64b12705e788859f1846f940)

![](https://3046938759-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MfWrOnV1iKerkfShm9O%2F-MgyDmz_nx3-eQCL2GRp%2F-MgyEEghy5gWv43lvLx7%2Fimage.png?alt=media\&token=2aa1d68c-d0c2-4fe6-b9fb-7b0a58faebfb)

## Monaca クラウド IDE でプラグインを有効にする

1. IDE メニューか&#x3089;**`設定 → Cordova プラグインの管理`**&#x3078;移動します。
2. `Cordova プラグインのインポート`ボタンをクリックします。 次に、\[ZIP ファイル] または \[パッケージ名 / URL] を使用してプラグインをインポートします。

## API リファレンス

このページでは、[デモ](https://monaca.mobi/directimport?pid=5b29ede3e788853905dba6d9) で使用されている主な API についてのみ説明します。API リファレンスについては、[こちら](https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin) を参照してください。

### shareViaFacebook()

Facebook に共有する。

```javascript
window.plugins.socialsharing.shareViaFacebook(message, image, url)
```

{% hint style="info" %}
この機能を使用するには、端末の Facebook アプリで有効な認証が必要です。
{% endhint %}

**パラメーター**

| パラメーター名   | 型      | 説明          |
| --------- | ------ | ----------- |
| `message` | String | メッセージ       |
| `image`   | String | 画像のソース      |
| `url`     | String | Web サイトのURL |

{% hint style="info" %}
Facebookへの共有では `image` と `url` を同時に指定することはできません。

`image` を指定する場合は `url` は `null` を指定してください。
{% endhint %}

**戻り値**

* `Promise`

**例**

```javascript
  window.plugins.socialsharing.shareViaFacebook(
    'Sharing via Facebook', 
    img.src, 
    null
  );
```

### shareViaTwitter()

Twitter に共有する。

```javascript
window.plugins.socialsharing.shareViaTwitter(message, image, url)
```

{% hint style="info" %}
この機能を使用するには、端末の Twitter アプリで有効な認証が必要です。
{% endhint %}

**パラメーター**

| パラメーター名   | 型      | 説明          |
| --------- | ------ | ----------- |
| `message` | String | メッセージ       |
| `image`   | String | 画像のソース      |
| `url`     | String | Web サイトのURL |

**戻り値**

* `Promise`

**例**

```javascript
  window.plugins.socialsharing.shareViaTwitter(
    'Message and link via Twitter', 
    img.src, 
    "www.monaca.io" 
  );
```

### shareViaInstagram()

Instagram に共有する。

```javascript
window.plugins.socialsharing.shareViaInstagram(message, image)
```

{% hint style="info" %}
この機能を使用するには、端末の Instagram アプリに対する有効な認証が必要です。 この機能は、iOS では利用できません。
{% endhint %}

**パラメーター**

| パラメーター名   | 型      | 説明     |
| --------- | ------ | ------ |
| `message` | String | メッセージ  |
| `image`   | String | 画像のソース |

**戻り値**

* `Promise`

**例**

```javascript
  window.plugins.socialsharing.shareViaInstagram(
    'Message via Instagram', 
    img.src
  );
```
