community-cordova-plugin-social-sharing 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,177 @@
1
+ var cordova = require('cordova');
2
+
3
+ module.exports = {
4
+ share: function (win, fail, args) {
5
+ //Text Message
6
+ var message = args[0];
7
+ //Title
8
+ var subject = args[1];
9
+ //File(s) Path
10
+ var fileOrFileArray = args[2];
11
+ //Web link
12
+ var url = args[3];
13
+
14
+ var folder = Windows.Storage.ApplicationData.current.temporaryFolder;
15
+
16
+ var getExtension = function (strBase64) {
17
+ return strBase64.substring(strBase64.indexOf("/") + 1, strBase64.indexOf(";base64"));
18
+ };
19
+
20
+ var replaceAll = function (str, find, replace) {
21
+ return str.replace(new RegExp(find, 'g'), replace);
22
+ };
23
+
24
+ var sanitizeFilename = function (name) {
25
+ return replaceAll(name, "[:\\\\/*?|<> ]", "_");
26
+ };
27
+
28
+ var getFileName = function (position, fileExtension) {
29
+ var fileName = (subject ? sanitizeFilename(subject) : "file") + (position == 0 ? "" : "_" + position) + "." + fileExtension;
30
+ return fileName;
31
+ };
32
+
33
+ var createTemporalFile = function (fileName, buffer) {
34
+
35
+ var filePath = "";
36
+ return folder.createFileAsync(fileName, Windows.Storage.CreationCollisionOption.replaceExisting).then(function (file) {
37
+ filePath = file.path;
38
+ return Windows.Storage.FileIO.writeBufferAsync(file, buffer);
39
+ }).then(function(){
40
+ return Windows.Storage.StorageFile.getFileFromPathAsync(filePath);
41
+ });
42
+ };
43
+
44
+ var doShare = function (e) {
45
+ e.request.data.properties.title = subject?subject: "Sharing";
46
+ if (message) e.request.data.setText(message);
47
+ if (url) e.request.data.setWebLink(new Windows.Foundation.Uri(url));
48
+ if (fileOrFileArray.length > 0) {
49
+ var deferral = e.request.getDeferral();
50
+ var storageItems = [];
51
+ var filesCount = fileOrFileArray.length;
52
+
53
+ var completeFile = function () {
54
+ if (!--filesCount) {
55
+ storageItems.length && e.request.data.setStorageItems(storageItems);
56
+ deferral.complete();
57
+ }
58
+ };
59
+
60
+ for (var i = 0; i < fileOrFileArray.length; i++) {
61
+
62
+ var file = fileOrFileArray[i];
63
+ if (file.indexOf("data:") >= 0) {
64
+ var fileName = getFileName(i, getExtension(file));
65
+ var buffer = Windows.Security.Cryptography.CryptographicBuffer.decodeFromBase64String(file.split(',')[1]);
66
+ if (buffer) {
67
+ createTemporalFile(fileName, buffer).done(
68
+ function (file) {
69
+ storageItems.push(file);
70
+ completeFile();
71
+ },
72
+ function () {
73
+ completeFile();
74
+ }
75
+ );
76
+ }
77
+ else {
78
+ completeFile();
79
+ }
80
+ }
81
+ else {
82
+ Windows.Storage.StorageFile.getFileFromPathAsync(file).done(
83
+ function (file) {
84
+ storageItems.push(file);
85
+ completeFile();
86
+ },
87
+ function () {
88
+ completeFile();
89
+ }
90
+ );
91
+ }
92
+ }
93
+ }
94
+ };
95
+
96
+
97
+ var dataTransferManager = Windows.ApplicationModel.DataTransfer.DataTransferManager.getForCurrentView();
98
+
99
+ dataTransferManager.addEventListener("datarequested", doShare);
100
+
101
+ try {
102
+ Windows.ApplicationModel.DataTransfer.DataTransferManager.showShareUI();
103
+ win(true);
104
+ } catch (err) {
105
+ fail(err);
106
+ }
107
+ },
108
+
109
+ canShareViaEmail: function (win, fail, args) {
110
+ win(true);
111
+ },
112
+
113
+ shareViaEmail: function (win, fail, args) {
114
+ //Text Message
115
+ var message = args[0];
116
+ //Title
117
+ var subject = args[1];
118
+ //File(s) Path
119
+ var fileOrFileArray = args[5];
120
+
121
+ var doShare = function (e) {
122
+ e.request.data.properties.title = subject ? subject : "Sharing";
123
+ if (message) {
124
+ var htmlFormat = Windows.ApplicationModel.DataTransfer.HtmlFormatHelper.createHtmlFormat(message);
125
+ e.request.data.setHtmlFormat(htmlFormat);
126
+ }
127
+
128
+ if (fileOrFileArray.length > 0) {
129
+ var deferral = e.request.getDeferral();
130
+ var storageItems = [];
131
+ var filesCount = fileOrFileArray.length;
132
+ for (var i = 0; i < fileOrFileArray.length; i++) {
133
+ Windows.Storage.StorageFile.getFileFromPathAsync(fileOrFileArray[i]).done(
134
+ function (index, file) {
135
+ var path = fileOrFileArray[index];
136
+ var streamRef = Windows.Storage.Streams.RandomAccessStreamReference.createFromFile(file);
137
+ e.request.data.resourceMap[path] = streamRef;
138
+ storageItems.push(file);
139
+ if (!--filesCount) {
140
+ e.request.data.setStorageItems(storageItems);
141
+ deferral.complete();
142
+ }
143
+ }.bind(this, i),
144
+ function () {
145
+ if (!--filesCount) {
146
+ e.request.data.setStorageItems(storageItems);
147
+ deferral.complete();
148
+ }
149
+ }
150
+ );
151
+ }
152
+ }
153
+ };
154
+
155
+ var dataTransferManager = Windows.ApplicationModel.DataTransfer.DataTransferManager.getForCurrentView();
156
+
157
+ dataTransferManager.addEventListener("datarequested", doShare);
158
+
159
+ try {
160
+ Windows.ApplicationModel.DataTransfer.DataTransferManager.showShareUI();
161
+ win(true);
162
+ } catch (err) {
163
+ fail(err);
164
+ }
165
+ },
166
+
167
+ shareViaSMS: function (win, fail, args) {
168
+ var chatMessage = new Windows.ApplicationModel.Chat.ChatMessage();
169
+ chatMessage.body = args[0].message;
170
+ if (!!args[1]) {
171
+ chatMessage.recipients.push(args[1]);
172
+ }
173
+ Windows.ApplicationModel.Chat.ChatMessageManager.showComposeSmsMessageAsync(chatMessage).done(win, fail);
174
+ }
175
+ };
176
+
177
+ require("cordova/exec/proxy").add("SocialSharing", module.exports);
Binary file
@@ -0,0 +1,103 @@
1
+ using Microsoft.Phone.Tasks;
2
+
3
+ using WPCordovaClassLib.Cordova;
4
+ using WPCordovaClassLib.Cordova.Commands;
5
+ using WPCordovaClassLib.Cordova.JSON;
6
+
7
+ using Newtonsoft.Json;
8
+
9
+ namespace Cordova.Extension.Commands
10
+ {
11
+ public class SocialSharing : BaseCommand
12
+ {
13
+
14
+ public void available(string jsonArgs)
15
+ {
16
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK));
17
+ }
18
+
19
+ public void share(string jsonArgs)
20
+ {
21
+
22
+ var options = JsonHelper.Deserialize<string[]>(jsonArgs);
23
+
24
+ var message = options[0];
25
+ var title = options[1];
26
+ var files = JsonHelper.Deserialize<string[]>(options[2]);
27
+ var link = options[3];
28
+
29
+ if (link != null && !"null".Equals(link))
30
+ {
31
+ ShareLinkTask shareLinkTask = new ShareLinkTask();
32
+ shareLinkTask.Title = title;
33
+ shareLinkTask.LinkUri = new System.Uri(link, System.UriKind.Absolute);
34
+ shareLinkTask.Message = message;
35
+ shareLinkTask.Show();
36
+ }
37
+ else if (files != null && files.Length > 0)
38
+ {
39
+ ShareLinkTask shareLinkTask = new ShareLinkTask();
40
+ shareLinkTask.Title = title;
41
+ shareLinkTask.LinkUri = new System.Uri(files[0], System.UriKind.Absolute);
42
+ shareLinkTask.Message = message;
43
+ shareLinkTask.Show();
44
+ }
45
+ else
46
+ {
47
+ var shareStatusTask = new ShareStatusTask { Status = message };
48
+ shareStatusTask.Show();
49
+ }
50
+ // unfortunately, there is no way to tell if something was shared, so just invoke the successCallback
51
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK));
52
+ }
53
+
54
+ public void canShareViaEmail(string jsonArgs)
55
+ {
56
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK));
57
+ }
58
+
59
+ // HTML and attachments are currently not supported on WP8
60
+ public void shareViaEmail(string jsonArgs)
61
+ {
62
+ var options = JsonHelper.Deserialize<string[]>(jsonArgs);
63
+ EmailComposeTask draft = new EmailComposeTask();
64
+ draft.Body = options[0];
65
+ draft.Subject = options[1];
66
+ if (!"null".Equals(options[2]))
67
+ {
68
+ draft.To = string.Join(",", options[2]);
69
+ }
70
+ if (!"null".Equals(options[3]))
71
+ {
72
+ draft.Cc = string.Join(",", options[3]);
73
+ }
74
+ if (!"null".Equals(options[4]))
75
+ {
76
+ draft.Bcc = string.Join(",", options[4]);
77
+ }
78
+ draft.Show();
79
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, true));
80
+ }
81
+
82
+ public void shareViaSMS(string jsonArgs)
83
+ {
84
+ var options = JsonHelper.Deserialize<string[]>(jsonArgs);
85
+
86
+ SmsComposeTask smsComposeTask = new SmsComposeTask();
87
+
88
+ smsComposeTask.To = options[1];
89
+ SMSMessageClass m = JsonConvert.DeserializeObject<SMSMessageClass>(options[0]);
90
+ smsComposeTask.Body = m.message;
91
+
92
+ smsComposeTask.Show();
93
+
94
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, true));
95
+ }
96
+ }
97
+
98
+ public class SMSMessageClass
99
+ {
100
+ public string message { get; set; }
101
+ }
102
+
103
+ }
@@ -0,0 +1,62 @@
1
+ // Type definitions for PhoneGap / Cordova Social Sharing plugin
2
+ // Project: https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin
3
+ // Licensed under the MIT license.
4
+
5
+ interface Window {
6
+ plugins: Plugins
7
+ }
8
+
9
+ interface Plugins {
10
+ socialsharing: SocialSharing
11
+ }
12
+
13
+ interface Navigator {
14
+ share: SocialSharingW3C
15
+ }
16
+
17
+ declare class SocialSharing {
18
+ iPadPopupCoordinates: () => string
19
+ setIPadPopupCoordinates: (coords: string) => void
20
+ available: (callback: (available: boolean) => void) => void
21
+ shareWithOptions: (options: SocialSharingOptions, successCallback?: SocialSharingSuccessCallback<SocialSharingResult>, errorCallback?: SocialSharingErrorCallback) => void
22
+ shareW3C: SocialSharingW3C
23
+ share: (message?: string, subject?: string, fileOrFileArray?: string | ArrayLike<string>, url?: string, successCallback?: SocialSharingSuccessCallback<boolean>, errorCallback?: SocialSharingErrorCallback) => void
24
+ shareViaTwitter: (message?: string, file?: string, url?: string, successCallback?: SocialSharingSuccessCallback<boolean>, errorCallback?: SocialSharingErrorCallback) => void
25
+ shareViaFacebook: (message?: string, fileOrFileArray?: string | ArrayLike<string>, url?: string, successCallback?: SocialSharingSuccessCallback<boolean>, errorCallback?: SocialSharingErrorCallback) => void
26
+ shareViaFacebookWithPasteMessageHint: (message?: string, fileOrFileArray?: string | ArrayLike<string>, url?: string, pasteMessageHint?: string, successCallback?: SocialSharingSuccessCallback<boolean>, errorCallback?: SocialSharingErrorCallback) => void
27
+ shareViaWhatsApp: (message?: string, fileOrFileArray?: string | ArrayLike<string>, url?: string, successCallback?: SocialSharingSuccessCallback<never>, errorCallback?: SocialSharingErrorCallback) => void
28
+ shareViaWhatsAppToReceiver: (receiver?: string, message?: string, fileOrFileArray?: string | ArrayLike<string>, url?: string, successCallback?: SocialSharingSuccessCallback<never>, errorCallback?: SocialSharingErrorCallback) => void
29
+ shareViaWhatsAppToPhone: (phone?: string, message?: string, fileOrFileArray?: string | ArrayLike<string>, url?: string, successCallback?: SocialSharingSuccessCallback<never>, errorCallback?: SocialSharingErrorCallback) => void
30
+ shareViaSMS: (options?: SocialSharingOptions | string, phoneNumbers?: ArrayLike<string>, successCallback?: SocialSharingSuccessCallback<boolean>, errorCallback?: SocialSharingErrorCallback) => void
31
+ shareViaEmail: (message?: string, subject?: string, toArray?: ArrayLike<string>, ccArray?: ArrayLike<string>, bccArray?: ArrayLike<string>, fileOrFileArray?: string | ArrayLike<string>, successCallback?: SocialSharingSuccessCallback<boolean>, errorCallback?: SocialSharingErrorCallback) => void
32
+ canShareVia: (via: string, message?: string, subject?: string, fileOrFileArray?: string | ArrayLike<string>, successCallback?: SocialSharingSuccessCallback<never>, errorCallback?: SocialSharingErrorCallback) => void
33
+ canShareViaEmail: (successCallback?: SocialSharingSuccessCallback<never>, errorCallback?: SocialSharingErrorCallback) => void
34
+ shareViaInstagram: (message?: string, fileOrFileArray?: string | ArrayLike<string>, successCallback?: SocialSharingSuccessCallback<never>, errorCallback?: SocialSharingErrorCallback) => void
35
+ shareVia: (via: string, message?: string, subject?: string, fileOrFileArray?: string | ArrayLike<string>, url?: string, successCallback?: SocialSharingSuccessCallback<boolean>, errorCallback?: SocialSharingErrorCallback) => void
36
+ saveToPhotoAlbum: (fileOrFileArray?: string | ArrayLike<string>, successCallback?: SocialSharingSuccessCallback<never>, errorCallback?: SocialSharingErrorCallback) => void
37
+ }
38
+
39
+ type SocialSharingW3C = (shareData: SocialSharingW3CData) => Promise<SocialSharingResult>
40
+
41
+ interface SocialSharingW3CData {
42
+ title?: string
43
+ text?: string
44
+ url?: string
45
+ }
46
+
47
+ interface SocialSharingOptions {
48
+ message?: string
49
+ subject?: string
50
+ files?: ArrayLike<string>
51
+ url?: string
52
+ chooserTitle?: string
53
+ appPackageName?: string
54
+ }
55
+
56
+ type SocialSharingSuccessCallback<T> = (result: T) => void
57
+ type SocialSharingErrorCallback = (msg?: string) => void
58
+
59
+ interface SocialSharingResult {
60
+ completed: boolean
61
+ app?: string
62
+ }
@@ -0,0 +1,157 @@
1
+ function SocialSharing() {
2
+ }
3
+
4
+ // Override this method (after deviceready) to set the location where you want the iPad popup arrow to appear.
5
+ // If not overridden with different values, the popup is not used. Example:
6
+ //
7
+ // window.plugins.socialsharing.iPadPopupCoordinates = function() {
8
+ // return "100,100,200,300";
9
+ // };
10
+ SocialSharing.prototype.iPadPopupCoordinates = function () {
11
+ // left,top,width,height
12
+ return "-1,-1,-1,-1";
13
+ };
14
+
15
+ SocialSharing.prototype.setIPadPopupCoordinates = function (coords) {
16
+ console.log("Deprecated - setIPadPopupCoordinates no longer works since plugin version 5.5.0. See https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin/issues/1052");
17
+ // left,top,width,height
18
+ cordova.exec(function() {}, this._getErrorCallback(function() {}, "setIPadPopupCoordinates"), "SocialSharing", "setIPadPopupCoordinates", [coords]);
19
+ };
20
+
21
+ SocialSharing.prototype.available = function (callback) {
22
+ cordova.exec(function (avail) {
23
+ callback(avail ? true : false);
24
+ }, null, "SocialSharing", "available", []);
25
+ };
26
+
27
+ // this is the recommended way to share as it is the most feature-rich with respect to what you pass in and get back
28
+ SocialSharing.prototype.shareWithOptions = function (options, successCallback, errorCallback) {
29
+ cordova.exec(successCallback, this._getErrorCallback(errorCallback, "shareWithOptions"), "SocialSharing", "shareWithOptions", [options]);
30
+ };
31
+
32
+ SocialSharing.prototype.shareW3C = function (sharedata) {
33
+ return new Promise(function(resolve, reject) {
34
+ var options = {
35
+ subject: sharedata.title,
36
+ message: sharedata.text,
37
+ url: sharedata.url,
38
+ iPadCoordinates: sharedata.iPadCoordinates || undefined
39
+ };
40
+ if(sharedata.hasOwnProperty('title') ||
41
+ sharedata.hasOwnProperty('text') ||
42
+ sharedata.hasOwnProperty('url')) {
43
+ cordova.exec(resolve, reject, "SocialSharing", "shareWithOptions", [options]);
44
+ } else {
45
+ reject();
46
+ }
47
+ });
48
+ };
49
+
50
+ SocialSharing.prototype.share = function (message, subject, fileOrFileArray, url, iPadCoordinates, successCallback, errorCallback) {
51
+ if (typeof iPadCoordinates === 'function') {
52
+ errorCallback = successCallback;
53
+ successCallback = iPadCoordinates;
54
+ iPadCoordinates = "";
55
+ }
56
+ cordova.exec(successCallback, this._getErrorCallback(errorCallback, "share"), "SocialSharing", "share", [message, subject, this._asArray(fileOrFileArray), url, iPadCoordinates]);
57
+ };
58
+
59
+ SocialSharing.prototype.shareViaTwitter = function (message, file /* multiple not allowed by twitter */, url, successCallback, errorCallback) {
60
+ var fileArray = this._asArray(file);
61
+ var ecb = this._getErrorCallback(errorCallback, "shareViaTwitter");
62
+ if (fileArray.length > 1) {
63
+ ecb("shareViaTwitter supports max one file");
64
+ } else {
65
+ cordova.exec(successCallback, ecb, "SocialSharing", "shareViaTwitter", [message, null, fileArray, url]);
66
+ }
67
+ };
68
+
69
+ SocialSharing.prototype.shareViaFacebook = function (message, fileOrFileArray, url, successCallback, errorCallback) {
70
+ cordova.exec(successCallback, this._getErrorCallback(errorCallback, "shareViaFacebook"), "SocialSharing", "shareViaFacebook", [message, null, this._asArray(fileOrFileArray), url]);
71
+ };
72
+
73
+ SocialSharing.prototype.shareViaFacebookWithPasteMessageHint = function (message, fileOrFileArray, url, pasteMessageHint, successCallback, errorCallback) {
74
+ pasteMessageHint = pasteMessageHint || "If you like you can paste a message from your clipboard";
75
+ cordova.exec(successCallback, this._getErrorCallback(errorCallback, "shareViaFacebookWithPasteMessageHint"), "SocialSharing", "shareViaFacebookWithPasteMessageHint", [message, null, this._asArray(fileOrFileArray), url, pasteMessageHint]);
76
+ };
77
+
78
+ SocialSharing.prototype.shareViaWhatsApp = function (message, fileOrFileArray, url, successCallback, errorCallback) {
79
+ cordova.exec(successCallback, this._getErrorCallback(errorCallback, "shareViaWhatsApp"), "SocialSharing", "shareViaWhatsApp", [message, null, this._asArray(fileOrFileArray), url, null, null]);
80
+ };
81
+
82
+ SocialSharing.prototype.shareViaWhatsAppToReceiver = function (receiver, message, fileOrFileArray, url, successCallback, errorCallback) {
83
+ cordova.exec(successCallback, this._getErrorCallback(errorCallback, "shareViaWhatsAppToReceiver"), "SocialSharing", "shareViaWhatsApp", [message, null, this._asArray(fileOrFileArray), url, receiver, null]);
84
+ };
85
+
86
+ SocialSharing.prototype.shareViaWhatsAppToPhone = function (phone, message, fileOrFileArray, url, successCallback, errorCallback) {
87
+ cordova.exec(successCallback, this._getErrorCallback(errorCallback, "shareViaWhatsAppToPhone"), "SocialSharing", "shareViaWhatsApp", [message, null, this._asArray(fileOrFileArray), url, null, phone]);
88
+ };
89
+
90
+ SocialSharing.prototype.shareViaSMS = function (options, phonenumbers, successCallback, errorCallback) {
91
+ var opts = options;
92
+ if (typeof options === "string") {
93
+ opts = {"message":options}; // for backward compatibility as the options param used to be the message
94
+ }
95
+ cordova.exec(successCallback, this._getErrorCallback(errorCallback, "shareViaSMS"), "SocialSharing", "shareViaSMS", [opts, phonenumbers]);
96
+ };
97
+
98
+ SocialSharing.prototype.shareViaEmail = function (message, subject, toArray, ccArray, bccArray, fileOrFileArray, successCallback, errorCallback) {
99
+ cordova.exec(successCallback, this._getErrorCallback(errorCallback, "shareViaEmail"), "SocialSharing", "shareViaEmail", [message, subject, this._asArray(toArray), this._asArray(ccArray), this._asArray(bccArray), this._asArray(fileOrFileArray)]);
100
+ };
101
+
102
+ SocialSharing.prototype.canShareVia = function (via, message, subject, fileOrFileArray, url, successCallback, errorCallback) {
103
+ cordova.exec(successCallback, this._getErrorCallback(errorCallback, "canShareVia"), "SocialSharing", "canShareVia", [message, subject, this._asArray(fileOrFileArray), url, via]);
104
+ };
105
+
106
+ SocialSharing.prototype.canShareViaEmail = function (successCallback, errorCallback) {
107
+ cordova.exec(successCallback, this._getErrorCallback(errorCallback, "canShareViaEmail"), "SocialSharing", "canShareViaEmail", []);
108
+ };
109
+
110
+ SocialSharing.prototype.shareViaInstagram = function (message, fileOrFileArray, successCallback, errorCallback) {
111
+ cordova.exec(successCallback, this._getErrorCallback(errorCallback, "shareViaInstagram"), "SocialSharing", "shareViaInstagram", [message, null, this._asArray(fileOrFileArray), null]);
112
+ };
113
+
114
+ SocialSharing.prototype.shareVia = function (via, message, subject, fileOrFileArray, url, successCallback, errorCallback) {
115
+ cordova.exec(successCallback, this._getErrorCallback(errorCallback, "shareVia"), "SocialSharing", "shareVia", [message, subject, this._asArray(fileOrFileArray), url, via]);
116
+ };
117
+
118
+ SocialSharing.prototype.saveToPhotoAlbum = function (fileOrFileArray, successCallback, errorCallback) {
119
+ cordova.exec(successCallback, this._getErrorCallback(errorCallback, "saveToPhotoAlbum"), "SocialSharing", "saveToPhotoAlbum", [this._asArray(fileOrFileArray)]);
120
+ };
121
+
122
+ SocialSharing.prototype._asArray = function (param) {
123
+ if (param == null) {
124
+ param = [];
125
+ } else if (typeof param === 'string') {
126
+ param = new Array(param);
127
+ }
128
+ return param;
129
+ };
130
+
131
+ SocialSharing.prototype._getErrorCallback = function (ecb, functionName) {
132
+ if (typeof ecb === 'function') {
133
+ return ecb;
134
+ } else {
135
+ return function (result) {
136
+ console.log("The injected error callback of '" + functionName + "' received: " + JSON.stringify(result));
137
+ }
138
+ }
139
+ };
140
+
141
+ SocialSharing.install = function () {
142
+ if (!window.plugins) {
143
+ window.plugins = {};
144
+ }
145
+
146
+ window.plugins.socialsharing = new SocialSharing();
147
+
148
+ // Note only polyfill navigator.share if it is not defined, since shareW3C implements L1 of the spec,
149
+ // and an existing navigator.share method could implement L2.
150
+ if (!navigator.share) {
151
+ navigator.share = window.plugins.socialsharing.shareW3C;
152
+ }
153
+
154
+ return window.plugins.socialsharing;
155
+ };
156
+
157
+ cordova.addConstructor(SocialSharing.install);