Cordova Social Sharing Plugin

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

To check the third party Cordova plugins, you need to create a custom build debugger (Android version or iOS version).

To use the plugin with the android custom build debugger, you need to import the cordova-plugin-androidx-adapter.

Demo

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. For complete API references, please refer to the repository.

shareViaFacebook()

Share to Facebook.

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

A valid authentication on the Facebook app on the device is required in order to use this function.

Parameter

Name

Type

Description

message

String

Message

image

String

Image's source

url

String

website url

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

Return Value

  • Promise

Example

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

shareViaTwitter()

Share to Twitter.

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

A valid authentication on the Twitter app on the device is required in order 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 the Instagram app on the device is required in order to use this function. This function does not work on iOS.

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
  );

Last updated