Bug 238713 - Web Share API: share() result promise never resolved if I save an image to the gallery
Summary: Web Share API: share() result promise never resolved if I save an image to th...
Status: RESOLVED DUPLICATE of bug 231995
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: Safari 15
Hardware: iPhone / iPad iOS 15
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-03 08:14 PDT by Riccardo Perra
Modified: 2022-04-03 14:04 PDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Riccardo Perra 2022-04-03 08:14:05 PDT
With share api, when the share() method is triggered, iOS provide several ways to share your data.

There is an unexpected behavior when the data parameter of the share() has an image file as a `files` property:
```
  const response = await fetch('500x500.png');
  const blob = await response.blob();
  const shareData = {files: [
    new File([blob], 'meme.png', {type: "image/png", lastModified: new Date().getTime()}),
  ]};
  navigator.share(shareData).then(() => {
    // never called if I save the image on the gallery
  }).catch((err) => [..]) 
```

- If the user click on "Save image" button to save the file in the gallery, the Promise will never be resolved
- If the user press again the button that trigger the share() method, the Promise will be rejected with this error:
"Not allowed error: The reequset is not allowed by the user agent or the platform in the current context, possibly because the user denied permission."

I published a github repo with the source code and reproducible example:


Demo: https://riccardoperra.github.io/webkit-save-image-broken-web-share-api/
Implementation: https://github.com/riccardoperra/webkit-save-image-broken-web-share-api/blob/main/src/main.ts
Comment 1 Tim Horton 2022-04-03 14:04:58 PDT

*** This bug has been marked as a duplicate of bug 231995 ***