Ilovexm24/www/js/share.js
2017-04-09 03:35:31 +02:00

20 lines
1 KiB
JavaScript

function shareMeNow(message, subject, url) {
// this is the complete list of currently supported params you can pass to the plugin (all optional)
var options = {
message: message ? entityToHtml(message) : '', // not supported on some apps (Facebook, Instagram)
subject: subject ? entityToHtml(subject) : 'Share this:', // fi. for email
//files: ['', ''], // an array of filenames either locally or remotely
url: url || 'https://www.ecn.org/xm24',
};
var onSuccess = function(result) {
console.log("Share completed? " + result.completed); // On Android apps mostly return false even while it's true
console.log("Shared to app: " + result.app); // On Android result.app is currently empty. On iOS it's empty when sharing is cancelled (result.completed=false)
};
var onError = function(msg) {
console.log("Sharing failed with message: " + msg);
};
window.plugins.socialsharing.shareWithOptions(options, onSuccess, onError);
}