EddyVerbruggen / SocialSharing-PhoneGap-Plugin

πŸ‘¨β€β€οΈβ€πŸ’‹β€πŸ‘¨ Cordova plugin to share text, a file (image/PDF/..), or a URL (or all three) via the native sharing widget
MIT License
1.78k stars 909 forks source link

Sharing local image url #610

Open dimnls opened 8 years ago

dimnls commented 8 years ago

Hi @EddyVerbruggen and thanks for the great plugin! I successfully managed to make it work and share an image when providing an external url (http://....) but I cannot manage to share a local image.

I tried passing 'images/myimage.png' which is the folder inside /www that the image is stored in, and GapDebug gives me the following error: The injected error callback of 'share' received: "URL_NOT_SUPPORTED" and the image is not loaded in the FB app.

I have also tried with 'myimage.png' and 'www/images/myimage.png' to no success.

I also tried 'file///myimage.png', Facebook seems to understand it's about to share an image but it cannot access it (image is blank and upload fails). This is after I added <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> in AndroidManifest.xml

For reference, this the function I'm using:

  socialShare(message: string = null, subject: string = null, file: string = 'all-over-again.png', link: string = null) {
    this.platform.ready().then(() => {
      if(window.plugins.socialsharing) {
        window.plugins.socialsharing.share(message, subject, file, link);
      }
    });
  }

I'm working on Ionic Framework 2 beta. Looking forward to any help!

jgamesl commented 8 years ago

Same problem here

emtzed commented 7 years ago

Had the same issue, but as a quick workaround you can do the following:

Instead of placing a 'static' URL, you can use a 'data' URL, like: window.plugins.socialsharing.share('test', null, 'data:image/png;base64,R0lGODlhDAAMALMBAP8AAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAUKAAEALAAAAAAMAAwAQAQZMMhJK7iY4p3nlZ8XgmNlnibXdVqolmhcRQA7', null, function(e){alert("success: " + e)}, function(e){alert("error: " + e)});

credits to this demo