iOS 14 Webshare API Broken

There is an example on MDN with Webshare API: mdn.github.io/dom-examples/web-share/

On iOS 14 device (test with iPhone 7 / iOS 14.0 / Safari) it works fine only once. For the second time it throws permission error:
Code Block
Error: NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.

Here are all the steps to reproduce:
  • Go to MDN Webshare API

  • Find a link to Web share test in "Examples" section and open it

  • Click "Share MDN!" button

  • Choose one of suggested options or just close sharing popover

  • Click on "Share MDN!" button again

  • See the error

Do you have any suggestions how to fix that? Is it a known bug?
Post not yet marked as solved Up vote post of inzeppelin Down vote post of inzeppelin
7.6k views
  • This issue is still occurs on the late IOS versions. tested on v15 and the problem is not resolved.

  • This is still happening on iOS 15 with those exact steps to reproduce.

Add a Comment

Replies

I just encountered the same problem in a web application I am working on. This also occurs on any device running iOS 14.0.1.

Refreshing the page restores the share functionality.

Something I have observed while debugging:
When you are able to get the share sheet to open the first time, the promise never resolves on successful share. The error also never resolves when you close the share sheet without sharing anything.

So something in the browser isn't reporting back to the API that the user closed the share sheet. Here's a little piece of code to see it in action (remember to open in https and on an iOS device since there is no error checking here)


Code Block javascript
navigator
.share({ title: 'test' })
.then(() => alert('complete'))
.catch((e) => alert(e))


I was going to hack together a workaround to hard refresh the webpage after the share completed, but since the promises never resolve, that won't work.

I don't have the iOS 14.2 beta, but I would be curious to see if it is fixed in that release.
I can confirm that the promise does not resolve after share

in safari web inspector
Code Block
Promise = $1
status: "pending"

Simple solution for now is to reload page if user tries to share again. Sharing again will reject the second share promise and you can then reload the page. The user will probably just click the button again and this time it will work.

Code Block
navigator.share(...)
.then(() => {
// this will never happen in IOS 14.0.1
})
.catch(error => {
//this will catch the second share attempt
window.location.reload(true); // now share works again
});

It is still a bug. For other tries to use share api gives error like this
Code Block js
NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.


It's already fixed by https://bugs.webkit.org/show_bug.cgi?id=216913

However, the fix is not in the 14.1 patch. Can we include it in the next patch of iOS? Thanks!
Maybe the fix has been shipped. I updated ios. When I share text, description and url to e.g. messenger or whatsapp, it only seems to share a hidden url, but no text is shared.
My exact same webshare API code works on an android phone. Could something have been omitted in the fix per accident ? Anyone with the same issue ?

This issue is still occurs on the late IOS 15 version, unfortunately this problem seems to be resolved on v14 but on v15 it is still persists.

Yeah, we just spend the last 6 months optimizing our webapp for mobile and are now only promoting it to Android users due to this issue... For webapps where saving files (e.g. images) is important to the workflow, this is a dealbreaker.

Its still problem on the IOS 16. First call of navigator.share will not resolve. So, it will throw Permission error after the second time.

  • Yes, it is still an issue.

  • Until a week ago I could enter to share a story on instagram. However, since this week it gives me an error directly when trying to share on instagram story, does anyone know why?

Add a Comment

This issue remains for 3 years now.

Our app works immediately great on Android but on iPhone cannot share image as data-url (e.g. image not displayed on whatsapp)

Did anyone found a way to work-around it?