Ilovexm24/www/js/share.js

20 lines
989 B
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 || 'share this', // not supported on some apps (Facebook, Instagram)
subject: subject || 'the subject', // fi. for email
//files: ['', ''], // an array of filenames either locally or remotely
url: url || 'https://www.website.com/foo/#bar?a=b',
}
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);
}