diff options
Diffstat (limited to 'StoneIsland/plugins/cordova-plugin-x-socialsharing/www/SocialSharing.js')
| -rw-r--r-- | StoneIsland/plugins/cordova-plugin-x-socialsharing/www/SocialSharing.js | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/www/SocialSharing.js b/StoneIsland/plugins/cordova-plugin-x-socialsharing/www/SocialSharing.js index 3fc9bb92..eea2a762 100644 --- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/www/SocialSharing.js +++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/www/SocialSharing.js @@ -28,6 +28,23 @@ SocialSharing.prototype.shareWithOptions = function (options, successCallback, e cordova.exec(successCallback, this._getErrorCallback(errorCallback, "shareWithOptions"), "SocialSharing", "shareWithOptions", [options]); }; +SocialSharing.prototype.shareW3C = function (sharedata) { + return new Promise(function(resolve, reject) { + var options = { + subject: sharedata.title, + message: sharedata.text, + url: sharedata.url + }; + if(sharedata.hasOwnProperty('title') || + sharedata.hasOwnProperty('text') || + sharedata.hasOwnProperty('url')) { + cordova.exec(resolve, reject, "SocialSharing", "shareWithOptions", [options]); + } else { + reject(); + } + }); +}; + SocialSharing.prototype.share = function (message, subject, fileOrFileArray, url, successCallback, errorCallback) { cordova.exec(successCallback, this._getErrorCallback(errorCallback, "share"), "SocialSharing", "share", [message, subject, this._asArray(fileOrFileArray), url]); }; @@ -116,7 +133,8 @@ SocialSharing.install = function () { } window.plugins.socialsharing = new SocialSharing(); + navigator.share = window.plugins.socialsharing.shareW3C; return window.plugins.socialsharing; }; -cordova.addConstructor(SocialSharing.install);
\ No newline at end of file +cordova.addConstructor(SocialSharing.install); |
