Cordova Social Sharing Plugin

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

Demo

Enable the Plugin in Monaca IDE

  1. From the IDE menu, go to Config → Manage Cordova Plugins .

  2. Click on Import Cordova Plugin button. Then, you can choose to import the plugin using a ZIP file or URL/Package Name.

API References

In this page, we only describe some main APIs used in our Demo. For a complete API references, please refer to here.

shareViaFacebook()

Share to Facebook.

window.plugins.socialsharing.shareViaFacebook(message, image, url)
A valid authentication on Facebook app on the device is required to use this function.

Parameter

Name Type Description
message String Message
image String Image’s source
url String website url

Return Value

  • Promise

Example

  window.plugins.socialsharing.shareViaFacebook(
    'Sharing via Facebook', 
    img.src, 
    "www.monaca.io"
  );

shareViaTwitter()

Share to Twitter.

window.plugins.socialsharing.shareViaTwitter(message, image, url)
A valid authentication on Twitter app on the device is required to use this function.

Parameter

Name Type Description
message String Message
image String Image’s source
url String website url

Return Value

  • Promise

Example

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

shareViaInstagram()

Share to Instagram.

window.plugins.socialsharing.shareViaInstagram(message, image)
A valid authentication on Instagram app on the device is required to use this function.

Parameter

Name Type Description
message String Message
image String Image’s source

Return Value

  • Promise

Example

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