Deep linking from Web to PWA (Standalone Version)

我怕爱的太早我们不能终老 提交于 2020-03-17 06:54:10

问题


I have a web app that it can be installed as standalone application in the homescreen thanks to PWA standard.

When a user forget his password, a email is sent to him with a link to reset the password.

Question is:

Can I deep-link to the already-installed standalone version instead of the web application in chrome browser? I'd like to achieve this behaviour:

  • User clicks in email link from gmail application.
  • OS check if link matches with any url schema pre-registered in the system (This is the step that I don't really know if it's possible from web right now)
  • If found, open the standalone version. Otherwise, open the browser.

Thanks in advance!

Cheers


回答1:


There is an example of describing intent filters in json here. The relevant section of the manifest is intent_filters

{
  "manifest_package": "org.chromium.webapk.test",
  "scope_url": "https://pwa.rocks/",
  "intent_filters": {
    "scope_url_scheme": "https",
    "scope_url_host": "pwa.rocks",
    "scope_url_path": "/"
  },
  "start_url": "https://pwa.rocks/",
  "display_mode": "standalone",
  "orientation": "portrait",
  "theme_color": "2147483648L",
  "background_color": "2147483648L",
  "icon_urls_and_icon_murmur2_hashes": "http://www.pwa.rocks/icon1.png 0 http://www.pwa.rocks/icon2.png 0",
  "web_manifest_url": "https://pwa.rocks/pwa.webmanifest",
  "version_code": "1",
  "version_name": "1.0",
  "bound_webapk": {
    "runtime_host": "org.chromium.chrome",
    "runtime_host_application_name": "Chromium"
  }
}



回答2:


If you set your scope properly in the manifest.json file, all links in other applications will open in the standalone version instead of the browser. Note that links in the browser will still prefer the browser version instead of the standalone. For example:

"start_url": "/",
"scope": "/",
"display": "standalone"

Note: Navigating directly to https://example.com/app/ from the address bar will work exactly as the same as it does for native apps that have an intent filter. Chrome assumes the user intended to visit the site and will open this site.

Source: developers.google.com/web/fundamentals/integration/webapks




回答3:


Configure the Android Intent Filters in Web App Manifest as shown here



来源:https://stackoverflow.com/questions/45979191/deep-linking-from-web-to-pwa-standalone-version

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!