-
Notifications
You must be signed in to change notification settings - Fork 313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
registerProtocolHandler
support triggering events in service worker instead of navigating to page
#1665
Comments
I added issues in Chrome and Firefox's bug trackers respectively: chromium-1399753 and mozilla-1804856. Because Safari doesn't support Sync some information. For now, this is not a detailed design, but to ask whether browser vendors would like to support this function. Current Native Apps BehaviorWhen click a registered protocol link, the native app is woken up and the link is passed to the app for processing. Note: the current page are not closed or navigate to other page, you can continue to click other links in the page that active the native app again. Current Web BehaviorAt present, when click a registered protocol link, Chrome navigate current page to the registered URL. In other words, current page is unload, you can't continue to click other links in this page. In some scenarios, this behavior is not expected, instead users expect the behavior like native apps. Of course, if the link has At present, the spec of registerProtocolHandler doesn't describe the detailed behavior what happen when click the link. The behavior depends on how the browser implements it. ProposalI hope registerProtocolHandler() can support native apps' behavior. When users click the link, fire an event with the link information in service worker, then the website(web app) can handle it in service worker, and the current page stay there. This approach is more flexible for developers, and the current page does not navigate to other page. For example, in service worker, developers can open a new tab or popup window, or active(focus) an already opened page or popup window to handle it. Below is a sample code for demonstration purpose:
|
Below is Andrew(Firefox)'s reply:
|
Here is my extended explanation. 1. PWA "protocol_handlers"https://developer.chrome.com/articles/url-protocol-handler/ 2. Firefox extension's "protocol_handlers"https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/protocol_handlers So both 1) and 2) are declarative ways, and are not general(universal) solution. My proposalMy proposal expands
|
(I post this on both service worker spec(here) and whatwg spec #8596)
I want to compare the behavior of web apps(and browser extensions) and native apps for a registered protocol.
Native apps behavior
When click a registered protocol link, the native app is woken up and the link is passed to the app for processing. Note: the current page doesn't be closed or navigate to other page, you can continue to click other links in the page and active the native app again.
Web behavior
Current
registerProtocolHandler()
spec says the behavior is "Navigate an appropriate navigable to resultURL". In other words, the current page is unload and navigate to another page. In some scenarios, this behavior is not expected, instead users expect the behavior like native apps.Proposal
I hope
registerProtocolHandler()
support another behavior like native apps behavior. When users click a registered protocol link, fire an event with the link information in service worker, then the website(web app) handle it in service work. This approach is more flexible for developers, and the current page does not navigate to other page. For example, in service worker, developers can open a new tab or popup window, or active(focus) an already opened page or popup window to handle it.The text was updated successfully, but these errors were encountered: