← Plugins / Social Sharing
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.
cordova plugin add cordova-plugin-x-socialsharing
The plugin is exposed as window.plugins.socialsharing after deviceready:
| Method | Description |
|---|---|
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 / shareViaSMS | Share directly through a specific channel. |
canShareVia(via, ..., success, error) | Check whether a given channel is available before showing a button. |
Open the native share sheet with a message and a link:
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);
}
);
}
shareWithOptions for the modern, flexible API rather than the positional share.canShareVia before showing a channel-specific button so you never offer an app the user doesn't have.