3

For a webapp I'm building I need to integrate file sharing capabilities. This is now finally possible since the IOS 15 release. However, I only got it partially working. When I share the file with email or messages it works fine. But when I try to share with whatsapp, signal or threema it will only share the title, not the actual file. I don't see any errors in the console or any failed network requests.


    const audioResponse = await fetch(sound.downloadUrl);
    
    const fileBuffer = await audioResponse.arrayBuffer();
    const fileArray = [
      new File([fileBuffer], name + '.mp3', {
        type: 'audio/mpeg',
        lastModified: Date.now(),
      }),
    ];
    if (
      window.navigator.canShare &&
      window.navigator.canShare({ files: fileArray })
    ) {
      navigator
        .share({
          files: fileArray,
          title: name,
          text: 'File share test',
        })
        .then(() => {
          console.log('Success!');
        })
        .catch(console.error);
    }

1 Answers1

6

I've found the solution. The issue was the title property in navigator.share This lead certain Apps on IOS to believe that I wanted to share the text and not the file.

Pretty frustrating since this works fine in other browsers but at least it's working now.

The following works:

navigator
        .share({
            files: fileArray,
        })
  • Were you able to share text as well or *only* the files? You say the `title` property was the issue but your working code also omits the `text` property. I'm trying to find a solution to share both if possible. – koktavy Sep 29 '21 at 15:46
  • I just tested, and you can't share any text if you want to share the image... – savram Oct 06 '21 at 19:35
  • 1
    Damn this needs to be fixed... – savram Oct 06 '21 at 19:48
  • I have confirmed this. It is not absolute. I've been testing it on iOS 15.5 on iPhone 7. Posting text images work on Twitter but not on WhatsApp or Facebook. I suspect Meta (Facebook and WhatsApp) is the cause (since it works just fine on Twitter). They need to fix this. The funny thing is, while it still can't post images and text at the same time, it still works on Instagram (where the text portion is removed). – Firanto Feb 08 '23 at 06:16