summaryrefslogtreecommitdiff
path: root/StoneIsland/plugins/cordova-plugin-x-socialsharing
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2020-09-10 14:35:21 +0200
committerJules Laplace <julescarbon@gmail.com>2020-09-10 14:35:21 +0200
commit3cf5e5a97afe8fc7877b528cf19130bef0d68bad (patch)
treeb2ba8044cb293716af3f3330903aea1d7b6bfcd9 /StoneIsland/plugins/cordova-plugin-x-socialsharing
parent50bf754c8742a5b7d054b9d93f9d4e37c1641a01 (diff)
build the app
Diffstat (limited to 'StoneIsland/plugins/cordova-plugin-x-socialsharing')
-rw-r--r--StoneIsland/plugins/cordova-plugin-x-socialsharing/.npmignore3
-rw-r--r--StoneIsland/plugins/cordova-plugin-x-socialsharing/.travis.yml4
-rw-r--r--StoneIsland/plugins/cordova-plugin-x-socialsharing/LICENSE (renamed from StoneIsland/plugins/cordova-plugin-x-socialsharing/MIT)2
-rw-r--r--StoneIsland/plugins/cordova-plugin-x-socialsharing/README.md35
-rw-r--r--StoneIsland/plugins/cordova-plugin-x-socialsharing/package.json66
-rwxr-xr-xStoneIsland/plugins/cordova-plugin-x-socialsharing/plugin.xml22
-rw-r--r--StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-android-share.pngbin142454 -> 0 bytes
-rw-r--r--StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-ios6-share.pngbin48752 -> 0 bytes
-rw-r--r--StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-ios7-ipad-share.pngbin47118 -> 0 bytes
-rw-r--r--StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-ios7-share.pngbin342109 -> 0 bytes
-rw-r--r--StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-wp8-share.jpgbin33347 -> 0 bytes
-rw-r--r--StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshots-ios7-shareconfig.pngbin183133 -> 0 bytes
-rw-r--r--StoneIsland/plugins/cordova-plugin-x-socialsharing/src/android/nl/xservices/plugins/FileProvider.java5
-rw-r--r--StoneIsland/plugins/cordova-plugin-x-socialsharing/src/android/nl/xservices/plugins/SocialSharing.java36
-rw-r--r--StoneIsland/plugins/cordova-plugin-x-socialsharing/src/android/res/xml/sharing_paths.xml11
-rw-r--r--StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/NSString+SSURLEncoding.h (renamed from StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/NSString+URLEncoding.h)2
-rw-r--r--StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/NSString+SSURLEncoding.m (renamed from StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/NSString+URLEncoding.m)4
-rw-r--r--StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/SocialSharing.m80
-rw-r--r--StoneIsland/plugins/cordova-plugin-x-socialsharing/src/windows/SocialSharingProxy.js17
-rwxr-xr-xStoneIsland/plugins/cordova-plugin-x-socialsharing/src/wp8/Newtonsoft.Json.dllbin0 -> 374784 bytes
-rw-r--r--StoneIsland/plugins/cordova-plugin-x-socialsharing/tests/plugin.xml13
-rw-r--r--StoneIsland/plugins/cordova-plugin-x-socialsharing/tests/test.js363
-rw-r--r--StoneIsland/plugins/cordova-plugin-x-socialsharing/www/SocialSharing.js20
23 files changed, 236 insertions, 447 deletions
diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/.npmignore b/StoneIsland/plugins/cordova-plugin-x-socialsharing/.npmignore
new file mode 100644
index 00000000..b9691135
--- /dev/null
+++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/.npmignore
@@ -0,0 +1,3 @@
+.idea
+screenshots
+tests \ No newline at end of file
diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/.travis.yml b/StoneIsland/plugins/cordova-plugin-x-socialsharing/.travis.yml
new file mode 100644
index 00000000..b9af4c58
--- /dev/null
+++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/.travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+sudo: false
+node_js:
+ - "4.2"
diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/MIT b/StoneIsland/plugins/cordova-plugin-x-socialsharing/LICENSE
index f932f6d9..7aa3caf0 100644
--- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/MIT
+++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/LICENSE
@@ -1,7 +1,5 @@
The MIT License (MIT)
-Copyright (c) 2014-2016 Eddy Verbruggen
-
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/README.md b/StoneIsland/plugins/cordova-plugin-x-socialsharing/README.md
index 52e5515c..7ab40f21 100644
--- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/README.md
+++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/README.md
@@ -205,14 +205,14 @@ Example: share a PDF file from the local www folder:
### Sharing directly to..
-####Twitter
+#### Twitter
```html
<!-- unlike most apps Twitter doesn't like it when you use an array to pass multiple files as the second param -->
<button onclick="window.plugins.socialsharing.shareViaTwitter('Message via Twitter')">message via Twitter</button>
<button onclick="window.plugins.socialsharing.shareViaTwitter('Message and link via Twitter', null /* img */, 'http://www.x-services.nl')">msg and link via Twitter</button>
```
-####Facebook
+#### Facebook
```html
<button onclick="window.plugins.socialsharing.shareViaFacebook('Message via Facebook', null /* img */, null /* url */, function() {console.log('share ok')}, function(errormsg){alert(errormsg)})">msg via Facebook (with errcallback)</button>
```
@@ -234,7 +234,7 @@ Whitelisting Facebook in your app's .plist:
</array>
```
-####Instagram
+#### Instagram
```html
<button onclick="window.plugins.socialsharing.shareViaInstagram('Message via Instagram', 'https://www.google.nl/images/srpr/logo4w.png', function() {console.log('share ok')}, function(errormsg){alert(errormsg)})">msg via Instagram</button>
```
@@ -266,7 +266,7 @@ Don't pass in an image on iOS because that can't be sent to someone directly unf
On Android pass in the phone number of the person you want to send a message to (untested at the moment).
-####SMS
+#### SMS
Note that on Android, SMS via Hangouts may not behave correctly
```html
<!-- Want to share a prefilled SMS text? -->
@@ -277,7 +277,7 @@ Note that on Android, SMS via Hangouts may not behave correctly
<button onclick="window.plugins.socialsharing.shareViaSMS({'message':'My cool message', 'subject':'The subject', 'image':'https://www.google.nl/images/srpr/logo4w.png'}, '0612345678,0687654321', function(msg) {console.log('ok: ' + msg)}, function(msg) {alert('error: ' + msg)})">share via SMS</button>
```
-####Email
+#### Email
Code inspired by the [EmailComposer plugin](https://github.com/katzer/cordova-plugin-email-composer), note that this is not supported on the iOS 8 simulator (an alert will be shown if your try to).
```js
window.plugins.socialsharing.shareViaEmail(
@@ -419,6 +419,23 @@ Here's the list of available activities you can disable :
- com.apple.UIKit.activity.AddToReadingList
- com.apple.UIKit.activity.AirDrop
+#### Web Share API
+
+Chrome is introducing a new [Web Share API](https://github.com/WICG/web-share) to share data.
+
+```js
+navigator.share({
+ 'title': 'Optional title',
+ 'text': 'Optional message',
+ 'url': 'http://www.myurl.com'
+}).then(function() {
+ console.log('Successful share');
+}).catch(function(error) {
+ console.log('Error sharing:', error)
+});
+```
+
+It doesn't provide all the options that the other share methods do but it is spec compliant.
## 4b. Usage on Windows Phone
The available methods on WP8 are: `available`, `canShareViaEmail`, `share`, `shareViaEmail` and `shareViaSMS`.
@@ -496,7 +513,7 @@ This is a stright forward approach - you just manually edit the .plist file - ei
There is a plugin designed specifically to address query schema whitelisting. You can find the plugin and how to use it [here](https://www.npmjs.com/package/cordova-plugin-queries-schemes). In general, after installation, you can change plugin.xml file under the plugin subfolder within the plugins directory of your project to add the required schemas. Here again though, you have to edit an additional file and should take care not to overwrite it when making changes to your project.
### Use Custom Config plugin
-The Custom Config plugin ([here](https://github.com/dpa99c/cordova-custom-config)) allows you to add configuration to your platforms "native" configuration files (e.g. .plist or AndroidManifest.xml) through the project's main config.xml file.
+The Custom Config plugin ([here](https://github.com/dpa99c/cordova-custom-config)) allows you to add configuration to your platforms "native" configuration files (e.g. .plist or AndroidManifest.xml) through the project's main config.xml file.
To address query schema issue, after installaing the plugin you can edit the iOS platform section of your config.xml (in the project main folder) to include the required entries:
@@ -506,11 +523,11 @@ To address query schema issue, after installaing the plugin you can edit the iOS
version="0.9.1"
xmlns="http://www.w3.org/ns/widgets"
xmlns:cdv="http://cordova.apache.org/ns/1.0">
-
+
<!-- a bunch of elements like name, description etc -->
-
+
<platform name="ios">
-
+
<!-- add this entry -->
<config-file platform="ios" target="*-Info.plist" parent="LSApplicationQueriesSchemes">
<array>
diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/package.json b/StoneIsland/plugins/cordova-plugin-x-socialsharing/package.json
index 62e6a1c0..b06fe392 100644
--- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/package.json
+++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/package.json
@@ -1,19 +1,53 @@
{
- "name": "cordova-plugin-x-socialsharing",
- "version": "5.1.3",
- "description": "Share text, images (and other files), or a link via the native sharing widget of your device. Android is fully supported, as well as iOS 6 and up. WP8 has somewhat limited support.",
+ "_from": "cordova-plugin-x-socialsharing@~5.1.3",
+ "_id": "cordova-plugin-x-socialsharing@5.1.8",
+ "_inBundle": false,
+ "_integrity": "sha1-Q5odL0c2YnYogm5Rla5Tm1TmJIo=",
+ "_location": "/cordova-plugin-x-socialsharing",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "range",
+ "registry": true,
+ "raw": "cordova-plugin-x-socialsharing@~5.1.3",
+ "name": "cordova-plugin-x-socialsharing",
+ "escapedName": "cordova-plugin-x-socialsharing",
+ "rawSpec": "~5.1.3",
+ "saveSpec": null,
+ "fetchSpec": "~5.1.3"
+ },
+ "_requiredBy": [
+ "/"
+ ],
+ "_resolved": "https://registry.npmjs.org/cordova-plugin-x-socialsharing/-/cordova-plugin-x-socialsharing-5.1.8.tgz",
+ "_shasum": "439a1d2f4736627628826e5195ae539b54e6248a",
+ "_spec": "cordova-plugin-x-socialsharing@~5.1.3",
+ "_where": "/Users/user/Sites/stone-island/StoneIsland",
+ "author": {
+ "name": "Eddy Verbruggen - @EddyVerbruggen"
+ },
+ "bugs": {
+ "url": "https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin/issues"
+ },
+ "bundleDependencies": false,
"cordova": {
"id": "cordova-plugin-x-socialsharing",
"platforms": [
"ios",
"android",
- "wp8"
+ "wp8",
+ "windows",
+ "web"
]
},
- "repository": {
- "type": "git",
- "url": "git+https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin.git"
- },
+ "deprecated": false,
+ "description": "Share text, images (and other files), or a link via the native sharing widget of your device. Android is fully supported, as well as iOS 6 and up. WP8 has somewhat limited support.",
+ "engines": [
+ {
+ "name": "cordova",
+ "version": ">=3.0.0"
+ }
+ ],
+ "homepage": "https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin#readme",
"keywords": [
"Social",
"Share",
@@ -26,21 +60,17 @@
"Pocket",
"LinkedIn",
"cordova",
+ "WebShare",
"ecosystem:cordova",
"cordova-ios",
"cordova-android",
"cordova-windows"
],
- "engines": [
- {
- "name": "cordova",
- "version": ">=3.0.0"
- }
- ],
- "author": "Eddy Verbruggen - @EddyVerbruggen",
"license": "MIT",
- "bugs": {
- "url": "https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin/issues"
+ "name": "cordova-plugin-x-socialsharing",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin.git"
},
- "homepage": "https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin#readme"
+ "version": "5.1.8"
}
diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/plugin.xml b/StoneIsland/plugins/cordova-plugin-x-socialsharing/plugin.xml
index 0a367427..cb4bf8bf 100755
--- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/plugin.xml
+++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/plugin.xml
@@ -2,7 +2,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-x-socialsharing"
- version="5.1.3">
+ version="5.1.8">
<name>SocialSharing</name>
@@ -25,6 +25,8 @@
<engine name="cordova" version=">=3.0.0"/>
</engines>
+ <dependency id="es6-promise-plugin"/>
+
<js-module src="www/SocialSharing.js" name="SocialSharing">
<clobbers target="window.plugins.socialsharing" />
</js-module>
@@ -39,8 +41,8 @@
</feature>
</config-file>
- <header-file src="src/ios/NSString+URLEncoding.h"/>
- <source-file src="src/ios/NSString+URLEncoding.m"/>
+ <header-file src="src/ios/NSString+SSURLEncoding.h"/>
+ <source-file src="src/ios/NSString+SSURLEncoding.m"/>
<header-file src="src/ios/SocialSharing.h"/>
<source-file src="src/ios/SocialSharing.m"/>
@@ -61,7 +63,17 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
</config-file>
+ <config-file target="AndroidManifest.xml" parent="/manifest/application">
+ <provider android:authorities="${applicationId}.sharing.provider" android:exported="false" android:grantUriPermissions="true" android:name="nl.xservices.plugins.FileProvider">
+ <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/sharing_paths" />
+ </provider>
+ </config-file>
+
<source-file src="src/android/nl/xservices/plugins/SocialSharing.java" target-dir="src/nl/xservices/plugins"/>
+ <source-file src="src/android/nl/xservices/plugins/FileProvider.java" target-dir="src/nl/xservices/plugins"/>
+ <source-file src="src/android/res/xml/sharing_paths.xml" target-dir="res/xml"/>
+
+ <framework src="com.android.support:support-v4:24.1.1+" />
</platform>
<!-- wp8 -->
@@ -75,11 +87,11 @@
<source-file src="src/wp8/SocialSharing.cs" />
<framework src="src/wp8/Newtonsoft.Json.dll" custom="true"/>
</platform>
-
+
<!-- windows -->
<platform name="windows">
<js-module src="src/windows/SocialSharingProxy.js" name="SocialSharingProxy">
- <merges target="" />
+ <runs />
</js-module>
</platform>
diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-android-share.png b/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-android-share.png
deleted file mode 100644
index f3ab135f..00000000
--- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-android-share.png
+++ /dev/null
Binary files differ
diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-ios6-share.png b/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-ios6-share.png
deleted file mode 100644
index 63b0b4c5..00000000
--- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-ios6-share.png
+++ /dev/null
Binary files differ
diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-ios7-ipad-share.png b/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-ios7-ipad-share.png
deleted file mode 100644
index 640c94f8..00000000
--- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-ios7-ipad-share.png
+++ /dev/null
Binary files differ
diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-ios7-share.png b/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-ios7-share.png
deleted file mode 100644
index 7545d10d..00000000
--- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-ios7-share.png
+++ /dev/null
Binary files differ
diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-wp8-share.jpg b/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-wp8-share.jpg
deleted file mode 100644
index 0ced2eb5..00000000
--- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshot-wp8-share.jpg
+++ /dev/null
Binary files differ
diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshots-ios7-shareconfig.png b/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshots-ios7-shareconfig.png
deleted file mode 100644
index 3afe5fef..00000000
--- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/screenshots/screenshots-ios7-shareconfig.png
+++ /dev/null
Binary files differ
diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/android/nl/xservices/plugins/FileProvider.java b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/android/nl/xservices/plugins/FileProvider.java
new file mode 100644
index 00000000..ef862604
--- /dev/null
+++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/android/nl/xservices/plugins/FileProvider.java
@@ -0,0 +1,5 @@
+package nl.xservices.plugins;
+
+
+public class FileProvider extends android.support.v4.content.FileProvider {
+} \ No newline at end of file
diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/android/nl/xservices/plugins/SocialSharing.java b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/android/nl/xservices/plugins/SocialSharing.java
index 8de31da8..faa96ced 100644
--- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/android/nl/xservices/plugins/SocialSharing.java
+++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/android/nl/xservices/plugins/SocialSharing.java
@@ -34,6 +34,8 @@ import java.util.TimerTask;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import nl.xservices.plugins.FileProvider;
+
public class SocialSharing extends CordovaPlugin {
private static final String ACTION_AVAILABLE_EVENT = "available";
@@ -81,10 +83,10 @@ public class SocialSharing extends CordovaPlugin {
} else if (ACTION_SHARE_VIA_TWITTER_EVENT.equals(action)) {
return doSendIntent(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), "twitter", null, false, true);
} else if (ACTION_SHARE_VIA_FACEBOOK_EVENT.equals(action)) {
- return doSendIntent(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), "com.facebook.katana", null, false, true);
+ return doSendIntent(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), "com.facebook.katana", null, false, true, "com.facebook.composer.shareintent");
} else if (ACTION_SHARE_VIA_FACEBOOK_WITH_PASTEMESSAGEHINT.equals(action)) {
this.pasteMessage = args.getString(4);
- return doSendIntent(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), "com.facebook.katana", null, false, true);
+ return doSendIntent(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), "com.facebook.katana", null, false, true, "com.facebook.composer.shareintent");
} else if (ACTION_SHARE_VIA_WHATSAPP_EVENT.equals(action)) {
if (notEmpty(args.getString(4))) {
return shareViaWhatsAppDirectly(callbackContext, args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), args.getString(4));
@@ -169,6 +171,7 @@ public class SocialSharing extends CordovaPlugin {
}
} catch (Exception e) {
callbackContext.error(e.getMessage());
+ return;
}
// this was added to start the intent in a new window as suggested in #300 to prevent crashes upon return
@@ -215,6 +218,19 @@ public class SocialSharing extends CordovaPlugin {
}
private boolean doSendIntent(
+ final CallbackContext callbackContext,
+ final String msg,
+ final String subject,
+ final JSONArray files,
+ final String url,
+ final String appPackageName,
+ final String chooserTitle,
+ final boolean peek,
+ final boolean boolResult) {
+ return doSendIntent(callbackContext, msg, subject, files, url, appPackageName, chooserTitle, peek, boolResult, null);
+ }
+
+ private boolean doSendIntent(
final CallbackContext callbackContext,
final String msg,
final String subject,
@@ -223,7 +239,8 @@ public class SocialSharing extends CordovaPlugin {
final String appPackageName,
final String chooserTitle,
final boolean peek,
- final boolean boolResult) {
+ final boolean boolResult,
+ final String appName) {
final CordovaInterface mycordova = cordova;
final CordovaPlugin plugin = this;
@@ -243,6 +260,7 @@ public class SocialSharing extends CordovaPlugin {
Uri fileUri = null;
for (int i = 0; i < files.length(); i++) {
fileUri = getFileUriAndSetType(sendIntent, dir, files.getString(i), subject, i);
+ fileUri = FileProvider.getUriForFile(webView.getContext(), cordova.getActivity().getPackageName()+".sharing.provider", new File(fileUri.getPath()));
if (fileUri != null) {
fileUris.add(fileUri);
}
@@ -295,7 +313,7 @@ public class SocialSharing extends CordovaPlugin {
packageName = items[0];
passedActivityName = items[1];
}
- final ActivityInfo activity = getActivity(callbackContext, sendIntent, packageName);
+ final ActivityInfo activity = getActivity(callbackContext, sendIntent, packageName, appName);
if (activity != null) {
if (peek) {
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
@@ -369,6 +387,8 @@ public class SocialSharing extends CordovaPlugin {
String localImage = image;
if (image.endsWith("mp4") || image.endsWith("mov") || image.endsWith("3gp")){
sendIntent.setType("video/*");
+ } else if (image.endsWith("mp3")) {
+ sendIntent.setType("audio/x-mpeg");
} else {
sendIntent.setType("image/*");
}
@@ -432,7 +452,7 @@ public class SocialSharing extends CordovaPlugin {
final String encodedImg = image.substring(image.indexOf(";base64,") + 8);
sendIntent.setType(fileType);
saveFile(Base64.decode(encodedImg, Base64.DEFAULT), dir, sanitizeFilename(fileName));
- localImage = "file://" + dir + "/" + fileName;
+ localImage = "file://" + dir + "/" + sanitizeFilename(fileName);
} else if (!image.startsWith("file://")) {
throw new IllegalArgumentException("URL_NOT_SUPPORTED");
} else {
@@ -649,12 +669,14 @@ public class SocialSharing extends CordovaPlugin {
return null;
}
- private ActivityInfo getActivity(final CallbackContext callbackContext, final Intent shareIntent, final String appPackageName) {
+ private ActivityInfo getActivity(final CallbackContext callbackContext, final Intent shareIntent, final String appPackageName, final String appName) {
final PackageManager pm = webView.getContext().getPackageManager();
List<ResolveInfo> activityList = pm.queryIntentActivities(shareIntent, 0);
for (final ResolveInfo app : activityList) {
if ((app.activityInfo.packageName).contains(appPackageName)) {
- return app.activityInfo;
+ if (appName == null || (app.activityInfo.name).contains(appName)) {
+ return app.activityInfo;
+ }
}
}
// no matching app found
diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/android/res/xml/sharing_paths.xml b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/android/res/xml/sharing_paths.xml
new file mode 100644
index 00000000..278084a2
--- /dev/null
+++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/android/res/xml/sharing_paths.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<paths>
+ <external-path
+ name="Android/data/${applicationId}/socialsharing_downloads"
+ path="./socialsharing-downloads"/>
+
+ <root-path
+ name="root"
+ path="/"/>
+
+</paths> \ No newline at end of file
diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/NSString+URLEncoding.h b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/NSString+SSURLEncoding.h
index d7da331d..71447b60 100644
--- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/NSString+URLEncoding.h
+++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/NSString+SSURLEncoding.h
@@ -1,5 +1,5 @@
#import <Foundation/Foundation.h>
-@interface NSString (URLEncoding)
+@interface NSString (SSURLEncoding)
@property (readonly) NSString *URLEncodedString;
@end
diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/NSString+URLEncoding.m b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/NSString+SSURLEncoding.m
index b737626c..c8e746d3 100644
--- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/NSString+URLEncoding.m
+++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/NSString+SSURLEncoding.m
@@ -1,6 +1,6 @@
-#import "NSString+URLEncoding.h"
+#import "NSString+SSURLEncoding.h"
-@implementation NSString (URLEncoding)
+@implementation NSString (SSURLEncoding)
- (NSString*)URLEncodedString
{
NSString* result = (NSString *)CFBridgingRelease(
diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/SocialSharing.m b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/SocialSharing.m
index 014925bd..57336cd9 100644
--- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/SocialSharing.m
+++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/ios/SocialSharing.m
@@ -1,5 +1,5 @@
#import "SocialSharing.h"
-#import "NSString+URLEncoding.h"
+#import "NSString+SSURLEncoding.h"
#import <Cordova/CDV.h>
#import <Social/Social.h>
#import <Foundation/NSException.h>
@@ -137,7 +137,7 @@ static NSString *const kShareOptionUrl = @"url";
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
[activityVC setCompletionHandler:^(NSString *activityType, BOOL completed) {
[self cleanupStoredFiles];
- NSDictionary * result = @{@"completed":@(completed), @"app":activityType};
+ NSDictionary * result = @{@"completed":@(completed), @"app":activityType == nil ? @"" : activityType};
CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:result];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}];
@@ -361,21 +361,43 @@ static NSString *const kShareOptionUrl = @"url";
NSURL *file = [self getFile:path];
NSData* data = [fileManager contentsAtPath:file.path];
+ if (!data) {
+ CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"invalid attachment"];
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
+ return;
+ }
+
NSString* fileName;
NSString* mimeType;
NSString* basename = [self getBasenameFromAttachmentPath:path];
- if ([basename hasPrefix:@"data:"]) {
- mimeType = (NSString*)[[[basename substringFromIndex:5] componentsSeparatedByString: @";"] objectAtIndex:0];
- fileName = @"attachment.";
- fileName = [fileName stringByAppendingString:(NSString*)[[mimeType componentsSeparatedByString: @"/"] lastObject]];
- NSString *base64content = (NSString*)[[basename componentsSeparatedByString: @","] lastObject];
- data = [SocialSharing dataFromBase64String:base64content];
- } else {
- fileName = [basename pathComponents].lastObject;
- mimeType = [self getMimeTypeFromFileExtension:[basename pathExtension]];
- }
- [self.globalMailComposer addAttachmentData:data mimeType:mimeType fileName:fileName];
+ //Find data anywhere in string
+ NSRange rangeData = [basename rangeOfString:@"data:"];
+ if (rangeData.location == NSNotFound)
+ {
+ fileName = [basename pathComponents].lastObject;
+ mimeType = [self getMimeTypeFromFileExtension:[basename pathExtension]];
+ }
+ else
+ {
+ mimeType = (NSString*)[[[basename substringFromIndex:rangeData.location+rangeData.length] componentsSeparatedByString: @";"] objectAtIndex:0];
+
+ //Find df anywhere in string
+ NSRange rangeDF = [basename rangeOfString:@"df:"];
+ //If not found fallback to default name
+ if (rangeDF.location == NSNotFound) {
+ fileName = @"attachment.";
+ fileName = [fileName stringByAppendingString:(NSString*)[[mimeType componentsSeparatedByString: @"/"] lastObject]];
+ } else {
+ //Found, apply name
+ fileName = (NSString*)[[[basename substringFromIndex:rangeDF.location+rangeDF.length] componentsSeparatedByString: @";"] objectAtIndex:0];
+ }
+
+
+ NSString *base64content = (NSString*)[[basename componentsSeparatedByString: @","] lastObject];
+ data = [SocialSharing dataFromBase64String:base64content];
+ }
+ [self.globalMailComposer addAttachmentData:data mimeType:mimeType fileName:fileName];
}
}
@@ -479,7 +501,7 @@ static NSString *const kShareOptionUrl = @"url";
_command = command;
[self.commandDelegate runInBackground:^{
picker.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
- [[self getTopMostViewController] presentViewController:picker animated:YES completion:nil];
+ [[self getTopMostViewController] presentViewController:picker animated:NO completion:nil];
}];
} else {
CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"not available"];
@@ -694,6 +716,7 @@ static NSString *const kShareOptionUrl = @"url";
-(NSURL*)getFile: (NSString *)fileName {
NSURL *file = nil;
if (fileName != (id)[NSNull null]) {
+ NSRange rangeData = [fileName rangeOfString:@"data:"];
if ([fileName hasPrefix:@"http"]) {
NSURL *url = [NSURL URLWithString:fileName];
NSData *fileData = [NSData dataWithContentsOfURL:url];
@@ -706,14 +729,27 @@ static NSString *const kShareOptionUrl = @"url";
} else if ([fileName hasPrefix:@"file://"]) {
// stripping the first 6 chars, because the path should start with / instead of file://
file = [NSURL fileURLWithPath:[fileName substringFromIndex:6]];
- } else if ([fileName hasPrefix:@"data:"]) {
- // using a base64 encoded string
- // extract some info from the 'fileName', which is for example: data:text/calendar;base64,<encoded stuff here>
- NSString *fileType = (NSString*)[[[fileName substringFromIndex:5] componentsSeparatedByString: @";"] objectAtIndex:0];
- fileType = (NSString*)[[fileType componentsSeparatedByString: @"/"] lastObject];
- NSString *base64content = (NSString*)[[fileName componentsSeparatedByString: @","] lastObject];
- NSData *fileData = [SocialSharing dataFromBase64String:base64content];
- file = [NSURL fileURLWithPath:[self storeInFile:[NSString stringWithFormat:@"%@.%@", @"file", fileType] fileData:fileData]];
+ } else if (rangeData.location != NSNotFound ){
+ //If found "data:"
+ NSString *fileType = (NSString*)[[[fileName substringFromIndex:rangeData.location+rangeData.length] componentsSeparatedByString: @";"] objectAtIndex:0];
+
+ NSString* attachmentName;
+ //Find df anywhere in string
+ NSRange rangeDF = [fileName rangeOfString:@"df:"];
+ //If not found fallback to default name
+ if (rangeDF.location == NSNotFound) {
+ attachmentName = @"attachment.";
+ attachmentName = [attachmentName stringByAppendingString:(NSString*)[[fileType componentsSeparatedByString: @"/"] lastObject]];
+ } else {
+ //Found, apply name
+ attachmentName = (NSString*)[[[fileName substringFromIndex:rangeDF.location+rangeDF.length] componentsSeparatedByString: @";"] objectAtIndex:0];
+ }
+
+
+ NSString *base64content = (NSString*)[[fileName componentsSeparatedByString: @","] lastObject];
+ NSData* data = [SocialSharing dataFromBase64String:base64content];
+ file = [NSURL fileURLWithPath:[self storeInFile:attachmentName fileData:data]];
+
} else {
// assume anywhere else, on the local filesystem
file = [NSURL fileURLWithPath:fileName];
diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/windows/SocialSharingProxy.js b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/windows/SocialSharingProxy.js
index ff257d52..b52fa12f 100644
--- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/windows/SocialSharingProxy.js
+++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/windows/SocialSharingProxy.js
@@ -1,4 +1,4 @@
-var cordova = require('cordova');
+var cordova = require('cordova');
module.exports = {
share: function (win, fail, args) {
@@ -10,7 +10,7 @@ module.exports = {
var fileOrFileArray = args[2];
//Web link
var url = args[3];
-
+
var folder = Windows.Storage.ApplicationData.current.temporaryFolder;
var getExtension = function (strBase64) {
@@ -49,7 +49,7 @@ module.exports = {
var deferral = e.request.getDeferral();
var storageItems = [];
var filesCount = fileOrFileArray.length;
-
+
var completeFile = function () {
if (!--filesCount) {
storageItems.length && e.request.data.setStorageItems(storageItems);
@@ -60,7 +60,7 @@ module.exports = {
for (var i = 0; i < fileOrFileArray.length; i++) {
var file = fileOrFileArray[i];
- if (file.indexOf("data:") >= 0) {
+ if (file.indexOf("data:") >= 0) {
var fileName = getFileName(i, getExtension(file));
var buffer = Windows.Security.Cryptography.CryptographicBuffer.decodeFromBase64String(file.split(',')[1]);
if (buffer) {
@@ -162,6 +162,15 @@ module.exports = {
} catch (err) {
fail(err);
}
+ },
+
+ shareViaSMS: function (win, fail, args) {
+ var chatMessage = new Windows.ApplicationModel.Chat.ChatMessage();
+ chatMessage.body = args[0].message;
+ if (!!args[1]) {
+ chatMessage.recipients.push(args[1]);
+ }
+ Windows.ApplicationModel.Chat.ChatMessageManager.showComposeSmsMessageAsync(chatMessage).done(win, fail);
}
};
diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/wp8/Newtonsoft.Json.dll b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/wp8/Newtonsoft.Json.dll
new file mode 100755
index 00000000..b8194284
--- /dev/null
+++ b/StoneIsland/plugins/cordova-plugin-x-socialsharing/src/wp8/Newtonsoft.Json.dll
Binary files differ
diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/tests/plugin.xml b/StoneIsland/plugins/cordova-plugin-x-socialsharing/tests/plugin.xml
deleted file mode 100644
index 1ccb2217..00000000
--- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/tests/plugin.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
- xmlns:rim="http://www.blackberry.com/ns/widgets"
- xmlns:android="http://schemas.android.com/apk/res/android"
- id="nl.x-services.plugins.socialsharing.tests"
- version="4.3.15">
- <name>SocialSharing Tests</name>
- <author>Nicolas Oliver</author>
- <license>MIT</license>
-
- <js-module src="test.js" name="tests"></js-module>
-</plugin> \ No newline at end of file
diff --git a/StoneIsland/plugins/cordova-plugin-x-socialsharing/tests/test.js b/StoneIsland/plugins/cordova-plugin-x-socialsharing/tests/test.js
deleted file mode 100644
index ad1a8229..00000000
--- a/StoneIsland/plugins/cordova-plugin-x-socialsharing/tests/test.js
+++ /dev/null
@@ -1,363 +0,0 @@
-/**
- * Jasmine Based test suites
- *
- * Several of SocialSharing APIs cannot be automatically tested, because
- * they depend on user interaction in order to call success or fail
- * handlers. For most of them, there is a basic test that assert the presence of
- * the API.
- *
- * There are some cases that test automation can be applied, i.e in "canShareVia",
- * "canShareViaEmail" and "available" methods. For those cases, there is some level
- * of automatic test coverage.
- */
-exports.defineAutoTests = function () {
- 'use strict';
-
- describe('socialsharing', function () {
- it('should be defined', function () {
- expect(window.plugins.socialsharing).toBeDefined();
- });
-
- describe('share', function () {
- it('should be defined', function () {
- expect(window.plugins.socialsharing.share).toBeDefined();
- });
-
- it('should be a function', function () {
- expect(typeof window.plugins.socialsharing.share).toEqual('function');
- });
- });
-
- describe('shareVia', function () {
- it('should be defined', function () {
- expect(window.plugins.socialsharing.shareVia).toBeDefined();
- });
-
- it('should be a function', function () {
- expect(typeof window.plugins.socialsharing.shareVia).toEqual('function');
- });
- });
-
- describe('shareViaTwitter', function () {
- it('should be defined', function () {
- expect(window.plugins.socialsharing.shareViaTwitter).toBeDefined();
- });
-
- it('should be a function', function () {
- expect(typeof window.plugins.socialsharing.shareViaTwitter).toEqual('function');
- });
- });
-
- describe('shareViaFacebook', function () {
- it('should be defined', function () {
- expect(window.plugins.socialsharing.shareViaFacebook).toBeDefined();
- });
-
- it('should be a function', function () {
- expect(typeof window.plugins.socialsharing.shareViaFacebook).toEqual('function');
- });
- });
-
- describe('shareViaFacebookWithPasteMessageHint', function () {
- it('should be defined', function () {
- expect(window.plugins.socialsharing.shareViaFacebookWithPasteMessageHint).toBeDefined();
- });
-
- it('should be a function', function () {
- expect(typeof window.plugins.socialsharing.shareViaFacebookWithPasteMessageHint).toEqual('function');
- });
- });
-
- describe('shareViaWhatsApp', function () {
- it('should be defined', function () {
- expect(window.plugins.socialsharing.shareViaWhatsApp).toBeDefined();
- });
-
- it('should be a function', function () {
- expect(typeof window.plugins.socialsharing.shareViaWhatsApp).toEqual('function');
- });
- });
-
- describe('shareViaSMS', function () {
- it('should be defined', function () {
- expect(window.plugins.socialsharing.shareViaSMS).toBeDefined();
- });
-
- it('should be a function', function () {
- expect(typeof window.plugins.socialsharing.shareViaSMS).toEqual('function');
- });
- });
-
- describe('shareViaEmail', function () {
- it('should be defined', function () {
- expect(window.plugins.socialsharing.shareViaEmail).toBeDefined();
- });
-
- it('should be a function', function () {
- expect(typeof window.plugins.socialsharing.shareViaEmail).toEqual('function');
- });
- });
-
- describe('canShareVia', function () {
- it('should be defined', function () {
- expect(window.plugins.socialsharing.canShareVia).toBeDefined();
- });
-
- it('should be a function', function () {
- expect(typeof window.plugins.socialsharing.canShareVia).toEqual('function');
- });
-
- it('should always call callback or error function', function (done) {
- function onSuccess(data){
- expect(data).not.toEqual(null);
- done();
- }
-
- function onError(error){
- expect(error).not.toEqual(null);
- done();
- }
-
- window.plugins.socialsharing.canShareVia('dummytarget','dummymessage', null, null, null, onSuccess, onError);
- });
- });
-
- describe('canshareViaEmail', function(){
- it('should be defined', function () {
- expect(window.plugins.socialsharing.canShareViaEmail).toBeDefined();
- });
-
- it('should be a function', function () {
- expect(typeof window.plugins.socialsharing.canShareViaEmail).toEqual('function');
- });
-
- it('should always call callback or error function', function (done) {
- function onSuccess(data){
- expect(data).not.toEqual(null);
- done();
- }
-
- function onError(error){
- expect(error).not.toEqual(null);
- done();
- }
-
- window.plugins.socialsharing.canShareViaEmail(onSuccess, onError);
- });
- });
-
- describe('availabe', function(){
- it('should be defined', function () {
- expect(window.plugins.socialsharing.available).toBeDefined();
- });
-
- it('should be a function', function () {
- expect(typeof window.plugins.socialsharing.available).toEqual('function');
- });
-
- it('should return a boolean when called', function(done){
- window.plugins.socialsharing.available(function(isAvailable) {
- expect(typeof isAvailable).toEqual('boolean');
- done();
- });
- });
- });
- });
-};
-
-/**
- * Manual tests suites
- *
- * Some actions buttons to execute SocialSharing plugin methods
- */
-exports.defineManualTests = function (contentEl, createActionButton) {
- 'use strict';
-
- /** helper function to log messages in the log div element */
- function logMessage(message, color) {
- var log = document.getElementById('info'),
- logLine = document.createElement('div');
-
- if (color) {
- logLine.style.color = color;
- }
-
- logLine.innerHTML = message;
- log.appendChild(logLine);
- }
-
- /** helper function to clear the log div element */
- function clearLog() {
- var log = document.getElementById('info');
- log.innerHTML = '';
- }
-
- /** helper function to declare a not implemented test */
- function testNotImplemented(testName) {
- return function () {
- console.error(testName, 'test not implemented');
- };
- }
-
- /** init method called on deviceready event */
- function init() {}
-
- /** object to hold properties and configs */
- var TestSuite = {};
-
- TestSuite.getCanShareViaTarget = function(){
- return document.getElementById('inputCanShareVia').value;
- };
-
- TestSuite.$markup = '' +
- '<fieldset>' +
- '<legend>Available Tests</legend>' +
-
- '<h3>Available</h3>' +
- '<div id="buttonIsAvailable"></div>' +
- 'Expected result: Should log if the plugin is available or not' +
- '</fieldset>' +
-
- '<fieldset>' +
- '<legend>Share Tests</legend>' +
-
- '<h3>Share Message</h3>' +
- '<div id="buttonShareMessage"></div>' +
- 'Expected result: Should display share widget, and the message to share should contain "Message body"' +
-
- '<h3>Share Message with Subject</h3>' +
- '<div id="buttonShareMessageWithSubject"></div>' +
- 'Expected result: Should display share widget, and the message to share should contain "Message body", and the subject should be "Message subject"' +
-
- '<h3>Share Link</h3>' +
- '<div id="buttonShareLink"></div>' +
- 'Expected result: Should display share widget, and the message to share should contain "http://www.x-services.nl"' +
-
- '<h3>Share Message with Link</h3>' +
- '<div id="buttonShareMessageAndLink"></div>' +
- 'Expected result: Should display share widget, and the message to share should contain "Message body http://www.x-services.nl"' +
-
- '<h3>Share Image</h3>' +
- '<div id="buttonShareImage"></div>' +
- 'Expected result: Should display share widget, and the message to share should contain an image' +
-
- '<h3>Share Image in base 64</h3>' +
- '<div id="buttonShareImageBase64"></div>' +
- 'Expected result: Should display share widget, and the message to share should contain an image. The image is encoded in base 64' +
-
- '<h3>Share Image with Message</h3>' +
- '<div id="buttonShareMessageImage"></div>' +
- 'Expected result: Should display share widget, and the message to share should contain "Message body" and an image' +
-
- '<h3>Share Image with Message and Link</h3>' +
- '<div id="buttonShareMessageImageLink"></div>' +
- 'Expected result: Should display share widget, and the message to share should contain "Message body http://www.x-services.nl" and an image' +
-
- '<h3>Share Image with Message, Subject and Link</h3>' +
- '<div id="buttonShareMessageSubjectImageLink"></div>' +
- 'Expected result: Should display share widget, and the message to share should contain "Message body http://www.x-services.nl", "Message subject" as subject, and an image' +
- '</fieldset>' +
-
- '<fieldset>' +
- '<legend>Can Share Tests</legend>' +
-
- 'Target: <input id="inputCanShareVia" type="text"/><br>' +
-
- '<h3>Can Share via</h3>' +
- '<div id="buttonCanShareVia"></div>' +
- 'Expected result: should log OK if can share, or should log a list of available share targets' +
-
- '<h3>Can Share via Email</h3>' +
- '<div id="buttonCanShareViaEmail"></div>' +
- 'Expected result: should log OK if can share' +
- '</fieldset>' +
- '';
-
- contentEl.innerHTML = '<div id="info"></div>' + TestSuite.$markup;
-
- createActionButton('availabe', function () {
- clearLog();
- window.plugins.socialsharing.available(function(isAvailable) {
- var message = 'is this plugin available? ';
- message += isAvailable? 'Yes' : 'No';
-
- logMessage(message, isAvailable? 'green' : 'red');
- });
- }, 'buttonIsAvailable');
-
- createActionButton('share message', function () {
- window.plugins.socialsharing.share('Message body');
- }, 'buttonShareMessage');
-
- createActionButton('share message and subject', function () {
- window.plugins.socialsharing.share('Message body', 'Message subject');
- }, 'buttonShareMessageWithSubject');
-
- createActionButton('share link', function () {
- window.plugins.socialsharing.share(null, null, null, 'http://www.x-services.nl');
- }, 'buttonShareLink');
-
- createActionButton('share message and link', function () {
- window.plugins.socialsharing.share('Message body', null, null, 'http://www.x-services.nl');
- }, 'buttonShareMessageAndLink');
-
- createActionButton('share image', function () {
- window.plugins.socialsharing.share(null, null, 'https://www.google.nl/images/srpr/logo4w.png', null);
- }, 'buttonShareImage');
-
- createActionButton('share image base 64', function () {
- window.plugins.socialsharing.share(null, 'Android filename', 'data:image/png;base64,R0lGODlhDAAMALMBAP8AAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAUKAAEALAAAAAAMAAwAQAQZMMhJK7iY4p3nlZ8XgmNlnibXdVqolmhcRQA7', null);
- }, 'buttonShareImageBase64');
-
- createActionButton('share message with image', function () {
- window.plugins.socialsharing.share('Message body', null, 'https://www.google.nl/images/srpr/logo4w.png', null);
- }, 'buttonShareMessageImage');
-
- createActionButton('share message, image, and link', function () {
- window.plugins.socialsharing.share('Message body', null, 'https://www.google.nl/images/srpr/logo4w.png', 'http://www.x-services.nl');
- }, 'buttonShareMessageImageLink');
-
- createActionButton('share message, subject, image, and link', function () {
- window.plugins.socialsharing.share('Message body', 'Message subject', 'https://www.google.nl/images/srpr/logo4w.png', 'http://www.x-services.nl');
- }, 'buttonShareMessageSubjectImageLink');
-
- createActionButton('can share via', function () {
- var target = TestSuite.getCanShareViaTarget();
-
- if(!target){
- console.error('must have a canShareVia target');
- }
- else {
- clearLog();
- window.plugins.socialsharing.canShareVia(target, 'msg', null, null, null, function(e){
- console.log('canShareVia success, see log for more information');
- logMessage('canShareVia: ' + e,'green');
- }, function(e){
- console.error('canShareVia fail, see log for more information');
- var message = "Share targets<br>";
-
- message += "<ul>";
-
- e.forEach(function(target){
- message += "<li>" + target + "</li>";
- });
-
- message += "</ul>";
- logMessage(message,'red');
- });
- }
- }, 'buttonCanShareVia');
-
- createActionButton('can share via email', function () {
- clearLog();
- window.plugins.socialsharing.canShareViaEmail(function(e){
- console.log('canShareViaEmail success, see log for more information');
- logMessage('canShareViaEmail: ' + e,'green');
- }, function(e){
- console.error('canShareViaEmail fail, see log for more information');
- logMessage('canShareViaEmail: ' + e,'red');
- });
- }, 'buttonCanShareViaEmail');
-
- document.addEventListener('deviceready', init, false);
-};
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);