Skip to content

Commit efce8d6

Browse files
committed
Updated Share Target demo to new API.
Still uses url_template for backwards compatibility, setting a flag and showing some UI to indicate that the user agent is still using the old API.
1 parent 438a663 commit efce8d6

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

demos/manifest.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44
"start_url": "sharetarget.html",
55
"display": "standalone",
66
"share_target": {
7-
"url_template": "sharetarget.html?title={title}&text={text}&url={url}"
7+
"url_template": "sharetarget.html?oldapi=true&title={title}&text={text}&url={url}",
8+
"action": "sharetarget.html",
9+
"params": {
10+
"title": "title",
11+
"text": "text",
12+
"url": "url"
13+
}
814
},
915
"icons": [{
1016
"src": "images/icon-16.png",

demos/sharetarget.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ <h1>Web Share Target Test App</h1>
7575
logText("Title shared: " + parsedUrl.searchParams.get("title"));
7676
logText("Text shared: " + parsedUrl.searchParams.get("text"));
7777
logText("URL shared: " + parsedUrl.searchParams.get("url"));
78+
// We still have the old "url_template" member in the manifest, which is
79+
// how WST was previously specced and implemented in Chrome. If the user
80+
// agent uses that method, the "oldapi" parameter will be set.
81+
if (parsedUrl.searchParams.get("oldapi")) {
82+
logText("Your browser is using the deprecated 'url_template' Web Share "
83+
+ "Target API.", true);
84+
}
7885
}
7986

8087
window.addEventListener('load', onLoad);

0 commit comments

Comments
 (0)