File tree Expand file tree Collapse file tree 2 files changed +7
-25
lines changed Expand file tree Collapse file tree 2 files changed +7
-25
lines changed Original file line number Diff line number Diff line change @@ -51,11 +51,13 @@ shareButton.addEventListener('click', () => {
51
51
});
52
52
```
53
53
54
- You can also test in advance whether there are any installed apps or services
55
- that support sharing (so you can not show the button if you know it won't work):
54
+ Developers should be aware that not all user agents will provide
55
+ ` navigator.share ` (sometimes intentionally; for instance, a browser may not
56
+ provide it when running on a platform that has no share support). Feature
57
+ detection can be used to avoid showing a non-functioning button on a web page:
56
58
57
59
``` js
58
- if (! navigator .canShare () )
60
+ if (navigator .share === undefined )
59
61
shareButton .hidden = true ;
60
62
```
61
63
Original file line number Diff line number Diff line change @@ -66,28 +66,8 @@ modes, but not learn the identity of the chosen application):
66
66
* The data could not be delivered to the target app (e.g., the chosen app could
67
67
not be launched), or the target app explicitly rejected the share event.
68
68
69
- ## navigator.canShare
70
-
71
- ` navigator ` also provides a method for determining whether there are any
72
- applications that can handle sharing:
73
-
74
- ``` WebIDL
75
- partial interface Navigator {
76
- boolean canShare();
77
- };
78
- ```
79
-
80
- Returns ` true ` if there are one or more applications that could handle a share
81
- event (i.e., if ` share ` was called, would any applications be presented to the
82
- user?). May give false positives, but not false negatives (on some systems, it
83
- may not be possible to determine in advance whether any native applications
84
- support sharing, in which case ` canShare ` should return ` true ` ; ` false ` means
85
- that ` share ` will definitely fail). This can be used by websites to hide or
86
- disable the sharing UI, to avoid presenting a button that just fails when users
87
- press it.
88
-
89
- ** TODO(mgiuca)** : This may have to be asynchronous, so that the implementation
90
- can query the file system without blocking.
69
+ The ` navigator.share ` method should be ` undefined ` if the user agent does not
70
+ support any share targets.
91
71
92
72
## Share handlers
93
73
You can’t perform that action at this time.
0 commit comments