Social Sharing Remote Images

Is there any option out there that provides native social sharing for iOS & Android and allows sharing of remote files?

I’ve got standard sharing working with “@capacitor/share” however in order to share a file with that plugin it would have to be a local file. We’re trying to allow our members to share images hosted on our website without having to download the image first.

So then I found “@byteowls/capacitor-filesharer” and got that setup and running without errors, however that plugin is just doing nothing now. When I run ionic serve, and click the share button this plugin downloads the image to my computer. If I run ionic capacitor run android and open the app on my device, then click the share button, nothing happens. The console shows a response in the success callback but no share menu shows at all.

Am I doing something wrong? Is there a better plugin? Is this not possible right now?

1 Like

Hi friend, did you manage to solve the problem?

Hey there. Yep somewhat.

We’re using this plugin: Social Sharing | Cordova Social Sharing Plugin for Ionic Apps though in their notes it says install @awesome-cordova-plugins/social-sharing and instead we installed via @ionic-native/social-sharing… not sure why these docs are off.

Once we had those packages, in my vue component I import the package like this:

import { SocialSharing } from "@ionic-native/social-sharing";

Then in our code, if we want to share a remote file we do something like the following - depending on what info you want to include:


    const shareFile = async (imgSrc: string) => {
      const options = {
        subject: content.value.title,
        files: [imgSrc],
      };
      const result = await SocialSharing.shareWithOptions(options);
    };

where imgSrc is the remote url of the image. We found for larger files, like a 20mb video, this was unreliable and caused a few issues. For those files, we triggered a download to our apps cache folder and once downloaded used the same native share function but provided the local file URI instead of a remote URL.

Hopen that helps!

2 Likes

Hi, success. it worked out!
thanks.

FYI, @ionic-native has been renamed to @awesome-cordova-plugins. In order to get updates, you should use the @awesome-cordova-plugins packages

Thanks a ton for that info! Will make sure my team sets some time aside to review all the ones we’re using and get them updated.