Closed samarthagarwal closed 7 years ago
I'm having the same failure and error message when I try to send a base64 encoded file, with this code:
var options = {
message: tweetText, // not supported on some apps (Facebook, Instagram)
//subject: 'the subject', // fi. for email
files: [picture], // an array of filenames either locally or remotely
chooserTitle: 'Pick an app' // Android only, you can override the default share sheet title
};
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);
What does Google tell us about this error?
I am pretty sure it is something related to file permissions. I checked the permissions in the manifest file and it is okay. I could not find a solution that is why I posted here.
Same here with this code for trying to share file in /storage/emulated/0/
Code:
`var options = { message: 'share this', // not supported on some apps (Facebook, Instagram) //subject: 'the subject', // fi. for email files: ['file:///storage/emulated/0/CalendarExport.json'], // an array of filenames either locally or remotely chooserTitle: 'Pick an app' // Android only, you can override the default share sheet title }
var onSuccess = function (result) {
alert("Share completed? " + result.completed); // On Android apps mostly return false even while it's true
alert("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) {
alert("Sharing failed with message: " + msg);
}
window.plugins.socialsharing.shareWithOptions(options, onSuccess, onError);`
Think I got a clue:
I saw in /res/xml/sharing_paths.xml the following element:
<external-files-path name="socialsharing_downloads" path="socialsharing-downloads/" />
Checking my android.support.v4.content.FileProvider, there's no tag for that element, just:
private static final java.lang.String META_DATA_FILE_PROVIDER_PATHS = "android.support.FILE_PROVIDER_PATHS";
private static final java.lang.String TAG_ROOT_PATH = "root-path";
private static final java.lang.String TAG_FILES_PATH = "files-path";
private static final java.lang.String TAG_CACHE_PATH = "cache-path";
private static final java.lang.String TAG_EXTERNAL = "external-path";
private static final java.lang.String ATTR_NAME = "name";
private static final java.lang.String ATTR_PATH = "path";
So this class is using "external-path" as tag, not "external-files-path". I commented that element
in sharing_paths.xml and added following:
<external-path name="external_path" path="." />
Then, I ran application again and tried to share a PDF file with Gmail application, and the file appears now as attached. Now the problem is that when I send the message, file is not really sent; just the message without the file.
Hope this give some light on the issue and let's check if we can manage to make it work....
Just FYI my code sending base64 (which shouldn't even need to access a file location, right? Or perhaps there is a temp file being created?) works fine if I revert back to 5.1.1 of cordova-plugin-x-socialsharing on NPM.
I can confirm @rebrandsoftware that 5.1.1 works.
Have removed plugin and reinstalled version 5.1.1 too and works. Thanks for the info @rebrandsoftware
@rebrandsoftware Any particular reason to use 5.1.1 over 5.1.2 or 5.1.3? Did you test those and confirmed they have the same issue?
I'm asking because my main suspect is the PR I accepted recently which was part of 5.1.4..
@EddyVerbruggen everything works fine up to 5.1.3 and the bug appears once I upgrade to 5.1.4.
@macdonst thanks for confirming that - #748 is doing more harm than good it seems.
Although I can think of more fun things, I will be solving this this weekend.
I can reproduce the crash that was introduced with 5.1.4, but can't reproduce the problem that it tried to solve.
However, I've now pushed a change to this repo's master branch that's supposed to fix the problem for all cases.
Would be great if someone that had the problem with 5.1.3 and before on Android SDK 24+ could verify it works correctly.
Hey, no reason I chose 5.1.1 other than I saw someone else having luck with 5.1.1. I will see what happens with other versions in just a moment.
@rebrandsoftware no need as @macdonst already confirmed it, but if you want: please verify the latest from github works fine (not released to npm yet)
I can verify that the error I was having has been fixed in the latest from Github. However, I was testing on Android SDK 23. Sounds like you will still need confirmation from others with SDK 24+.
Correct. But a regression test never hurts, cheers!
The same error =( When I use shareViaWhatsApp
Just commenting that if anyone has a workaround, a temp hack, I'd definitely appreciate it.
Ok ok I'm sorry I tried with cordova plugin add cordova-plugin-x-socialsharing
and not work, but I tried cordova plugin add https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin.git
and now the plugin work!!!
@nicobytes so you've essentially tested the fix I asked folks to test, that's awesome š I'll release an update to npm today.
Released with 5.1.6.
I confirm now working again for Android, was not sharing files due to prior regression.
I am having this same issue on 6.0.3. Is anyone else?
I am getting the following error when trying to share a file from a remote URL.
Here is my code.