Skip to content

Commit

Permalink
Merge pull request #8 from mgiuca/remove-canshare
Browse files Browse the repository at this point in the history
Removed navigator.canShare.
  • Loading branch information
mgiuca authored Nov 3, 2016
2 parents 4742008 + 8dca335 commit 914d1bc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 25 deletions.
8 changes: 5 additions & 3 deletions docs/explainer.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ shareButton.addEventListener('click', () => {
});
```

You can also test in advance whether there are any installed apps or services
that support sharing (so you can not show the button if you know it won't work):
Developers should be aware that not all user agents will provide
`navigator.share` (sometimes intentionally; for instance, a browser may not
provide it when running on a platform that has no share support). Feature
detection can be used to avoid showing a non-functioning button on a web page:

```js
if (!navigator.canShare())
if (navigator.share === undefined)
shareButton.hidden = true;
```

Expand Down
25 changes: 3 additions & 22 deletions docs/interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,9 @@ modes, but not learn the identity of the chosen application):
* The data could not be delivered to the target app (e.g., the chosen app could
not be launched), or the target app explicitly rejected the share event.

## navigator.canShare

`navigator` also provides a method for determining whether there are any
applications that can handle sharing:

```WebIDL
partial interface Navigator {
boolean canShare();
};
```

Returns `true` if there are one or more applications that could handle a share
event (i.e., if `share` was called, would any applications be presented to the
user?). May give false positives, but not false negatives (on some systems, it
may not be possible to determine in advance whether any native applications
support sharing, in which case `canShare` should return `true`; `false` means
that `share` will definitely fail). This can be used by websites to hide or
disable the sharing UI, to avoid presenting a button that just fails when users
press it.

**TODO(mgiuca)**: This may have to be asynchronous, so that the implementation
can query the file system without blocking.
In a user agent that will never provide any share targets (e.g., on a platform
that does not support sharing) `navigator.share` SHOULD NOT be present, so that
sites can use feature detection to avoid showing sharing UI.

## Share handlers

Expand Down

0 comments on commit 914d1bc

Please sign in to comment.