Bug 244408 - navigator.canShare(data) returns true but navigator.share(data) results in Unhandled Promise Rejection when data contains both image and text field.
Summary: navigator.canShare(data) returns true but navigator.share(data) results in Un...
Status: RESOLVED DUPLICATE of bug 231995
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: Safari 15
Hardware: iPhone / iPad iOS 15
: P2 Blocker
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-26 13:52 PDT by spreadpando
Modified: 2022-08-30 11:20 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description spreadpando 2022-08-26 13:52:10 PDT
When passed a data object with both text, and image parameters, navigator.share() produces:

"Unhandled Promise Rejection: NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission."

This occurs even if navigator.canShare returns true when passed the same data object.

This prevents users from sharing image, text and urls at once and negatively impacts iOS users' abilities to share content on the web.


Not a duplicate, but could be related to:

https://bugs.webkit.org/show_bug.cgi?id=231995 


For now the Web Share 2 API remains broken on iOS.

Produced on iPhone X iOS 15.5 (19F77)
Comment 1 Marcos Caceres 2022-08-28 18:07:21 PDT
I'll try to reproduce, but there are a few things that can cause canShare() to return true, but still result in a NotAllowedError:  

1. .share() called multiple times before the first call's promise settles.
2. .share() is not initiated by user activation (or, more unlikely, there is no Window object).
3. Permissions policy violation, but this produces a different error string so we can rule this out.
Comment 2 Marcos Caceres 2022-08-28 18:34:35 PDT
Ok, confirmed. This is indeed being caused by 231995 and it's a result of 1 (because even though shares completes, the promise is not being resolved). Thus, subsequent calls to .share() cause the API to freeze.

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