DedrisFrameworkDedrisFramework

← Plugins  /  Social Sharing

📤

Social Sharing

cordova-plugin-x-socialsharing
iOS Android

This widely-used community plugin opens the native share sheet so users can send text, links, images and files to any installed app — Messages, Mail, WhatsApp, Twitter and more. You can present the generic share dialog or target a specific channel directly.

Installation

terminal
cordova plugin add cordova-plugin-x-socialsharing

API

The plugin is exposed as window.plugins.socialsharing after deviceready:

MethodDescription
share(message, subject, files, url, success, error)Open the generic share sheet with any combination of text, files and a URL.
shareWithOptions(options, success, error)Share using an options object (message, subject, files, url, chooserTitle).
shareViaEmail(...)Open the mail composer with recipients, subject and attachments.
shareViaTwitter / shareViaWhatsApp / shareViaSMSShare directly through a specific channel.
canShareVia(via, ..., success, error)Check whether a given channel is available before showing a button.

Usage example

Open the native share sheet with a message and a link:

www/js/app.js
function shareApp() {
  var options = {
    message: "Check out DedrisFramework!",
    subject: "Build mobile, the open way",
    url: "https://dedrisframework.com"
  };

  window.plugins.socialsharing.shareWithOptions(
    options,
    function (result) {
      console.log("Shared: " + result.completed);
    },
    function (err) {
      console.error("Share failed: " + err);
    }
  );
}

Tips

📚 Source: the technical reference on this page is based on the cordova-plugin-x-socialsharing project (MIT licensed), maintained by the open-source community and listed in Ionic Native. Descriptions and examples have been rewritten in DedrisFramework's own words. This plugin is not part of the Apache Cordova core.
← Back to plugins Start a project