# Cordova Social Sharing Plugin

This Cordova plugin is used to share text, files, images, and links via social networks, sms, and email.

* Repository: <https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin>
* Plugin ID/package name: `cordova-plugin-x-socialsharing`
* Tested version: `6.0.4`
* Repository: <https://github.com/EddyVerbruggen/cordova-plugin-actionsheet>
* Plugin ID/package name: `cordova-plugin-actionsheet`
* Tested version: `2.3.3`

{% hint style="info" %}
To check the third party Cordova plugins, you need to create a custom build debugger ([Android version](/products_guide/debugger/installation/debugger_android.md#build-and-install-a-custom-monaca-debugger) or [iOS version](/products_guide/debugger/installation/debugger_ios.md#building-a-custom-monaca-debugger)).
{% endhint %}

{% hint style="info" %}
To use the plugin with the android custom build debugger, you need to import the [cordova-plugin-androidx-adapter](https://github.com/dpa99c/cordova-plugin-androidx-adapter).
{% endhint %}

## Demo

[<img src="https://docs.monaca.io/images/common/import_img.png" alt="" data-size="line">Import the Social sharing demo to your Monaca account](https://monaca.mobi/ja/directimport?pid=64b12705e788859f1846f940)![](https://docs.monaca.io/images/samples/social_sharing.png)<br>

## Enable the plugin in Monaca IDE

1. From the IDE menu, go to **Config → Manage Cordova Plugins** .
2. Click the **Import Cordova Plugin** button. Then, you can choose to import the plugin using a ZIP file or a URL/package name.

## API references

This section describes some of the main functions used in the [Demo](https://monaca.mobi/directimport?pid=5b29ede3e788853905dba6d9). For complete API references, please refer to the [repository](https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin).

### shareViaFacebook()

Share to Facebook.

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

{% hint style="info" %}
A valid authentication on the Facebook app on the device is required in order to use this function.
{% endhint %}

**Parameter**

| Name      | Type   | Description    |
| --------- | ------ | -------------- |
| `message` | String | Message        |
| `image`   | String | Image's source |
| `url`     | String | website url    |

{% hint style="info" %}

```
When sharing to Facebook, image and url cannot be specified at the same time.
Specify null for url when sharing image.
```

{% endhint %}

**Return Value**

* `Promise`

**Example**

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

### shareViaTwitter()

Share to Twitter.

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

{% hint style="info" %}
A valid authentication on the Twitter app on the device is required in order to use this function.
{% endhint %}

**Parameter**

| Name      | Type   | Description    |
| --------- | ------ | -------------- |
| `message` | String | Message        |
| `image`   | String | Image's source |
| `url`     | String | website url    |

**Return Value**

* `Promise`

**Example**

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

### shareViaInstagram()

Share to Instagram.

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

{% hint style="info" %}
A valid authentication on the Instagram app on the device is required in order to use this function. This function does not work on iOS.
{% endhint %}

**Parameter**

| Name      | Type   | Description    |
| --------- | ------ | -------------- |
| `message` | String | Message        |
| `image`   | String | Image's source |

**Return Value**

* `Promise`

**Example**

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://en.docs.monaca.io/tutorials/social_sharing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
