From c9eb78035d1127a5945327f91546226c5b66e393 Mon Sep 17 00:00:00 2001 From: Matt Giuca Date: Thu, 21 Jul 2016 18:36:11 +1000 Subject: [PATCH 1/3] Removed navigator.canShare. Resolves #5. --- docs/explainer.md | 8 +++++--- docs/interface.md | 24 ++---------------------- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/docs/explainer.md b/docs/explainer.md index 9f8c8d2..b7b9f7f 100644 --- a/docs/explainer.md +++ b/docs/explainer.md @@ -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; ``` diff --git a/docs/interface.md b/docs/interface.md index dc72e34..b739f85 100644 --- a/docs/interface.md +++ b/docs/interface.md @@ -66,28 +66,8 @@ 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. +The `navigator.share` method should be `undefined` if the user agent does not +support any share targets. ## Share handlers From 50e6231615ccb5eca9f49316d103a693ec026598 Mon Sep 17 00:00:00 2001 From: Matt Giuca Date: Mon, 25 Jul 2016 10:58:16 +1000 Subject: [PATCH 2/3] Reword text about navigator.share being undefined. --- docs/interface.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/interface.md b/docs/interface.md index b739f85..4046052 100644 --- a/docs/interface.md +++ b/docs/interface.md @@ -66,8 +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. -The `navigator.share` method should be `undefined` if the user agent does not -support any share targets. +In a user agent that will never provide any share targets (e.g., on a platform +that does not support sharing) `navigator.share` SHOULD be `undefined`, so that +sites can use feature detection to avoid showing sharing UI. ## Share handlers From 8dca33542985808bc59038ad0a5dc73828c5d0f2 Mon Sep 17 00:00:00 2001 From: Matt Giuca Date: Thu, 3 Nov 2016 16:56:15 +1100 Subject: [PATCH 3/3] Reword undefined text some more. --- docs/interface.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/interface.md b/docs/interface.md index 4046052..0c97bfc 100644 --- a/docs/interface.md +++ b/docs/interface.md @@ -67,7 +67,7 @@ modes, but not learn the identity of the chosen application): not be launched), or the target app explicitly rejected the share event. In a user agent that will never provide any share targets (e.g., on a platform -that does not support sharing) `navigator.share` SHOULD be `undefined`, so that +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