在浏览器中使用URL打开已安装的PWA不起作用。

huangapple go评论70阅读模式
英文:

Opening installed PWA with a URL in browser not working

问题

我正在尝试让我安装的PWA在扫描QR码后通过浏览器打开相应的URL。我已经正确设置了这个吗,还是我理解错了什么吗,请问?

用于测试的PWA是从Chrome中安装的,并且我正在测试将上述URL放入Android手机上的Chrome浏览器中。

我要放入浏览器的URL是...

https://test.mysupersite.com?book=GGGGG

...其中 'book' 可以是任意5个字符的字母或数字。

我有一个名为 'web-app-origin-association' 的文件,它位于我的网站根目录下名为 '.well-known' 的文件夹中,即 https://test/mysupersite.com/.well-known。它包含:

{
    "web_apps": [
        {
            "manifest": "https://test.mysupersite.com/manifest.webmanifest",
            "details": {
                "paths": ["/*"]
            }
        }      
    ]
}

我的 Web Manifest 名为 'manifest.webmanifest',也位于我的网站根目录中...

https://test.mysupersite.com/manifest.webmanifest

它包含...

{
  "name": "MySuperSite",
  "short_name": "MySuperSite",
  "gcm_sender_id": "XX47XX2560XX",
  "display": "standalone",
  "gcm_user_visible_only": true,
  "start_url": "/?mode=standalone",
  "theme_color": "#ffffff",
  "related_applications": [{
    "platform": "webapp",
    "url": "https://test.mysupersite.com/manifest.webmanifest"
 }],
  "url_handlers": [
    {
      "origin": "https://test.mysupersite.com"
    },{
      "origin": "https://*.mysupersite.com" 
    }
  ],
  "background_color": "black",
  "description": "Do super things",
  "icons": [
    {
      "src": "/imgs/PWA-icon-512.png",
      "type": "image/png",
      "sizes": "512x512"
    },
    {
      "src": "/imgs/PWA-icon-192.png",
      "type": "image/png",
      "sizes": "192x192"
    }
 ]
 
}

如果我的PWA安装成功(它确实安装成功了),那么在Android手机的Chrome浏览器中输入 https://test.mysupersite.com?book=GGGGG 会打开已安装的PWA 吗?

我还尝试过在浏览器中输入 https://test.mysupersite.com(没有查询字符串),但也不起作用。

感谢您的时间和帮助。

英文:

I'm trying to get my installed PWA to open when a QR code opens a URL in a browser. Have I got this set up correctly, or am I misunderstanding something, please?

For testing my PWA was installed from Chrome, and I'm testing putting the above URL in a Chrome browser on an Android phone.

The URL I'm putting in my browser is...

https://test.mysupersite.com?book=GGGGG

...where 'book' could be any 5 character alpha-numeral

I have a file named web-app-origin-association which is in a folder named .well-known in the root of my website i.e https://test/mysupersite.com/.well-known. It contains:

{
    "web_apps": [
        {
            "manifest": "https://test.mysupersite.com/manifest.webmanifest",
            "details": {
                "paths": ["/*"]
            }
        }      
    ]
}

My web manifest is named manifest.webmanifest and is also in my site's root...

https://test.mysupersite.com/manifest.webmanifest

It contains...

{
  "name": "MySuperSite",
  "short_name": "MySuperSite",
  "gcm_sender_id": "XX47XX2560XX",
  "display": "standalone",
  "gcm_user_visible_only": true,
  "start_url": "/?mode=standalone",
  "theme_color": "#ffffff",
  "related_applications": [{
    "platform": "webapp",
    "url": "https://test.mysupersite.com/manifest.webmanifest"
 }],
  "url_handlers": [
    {
      "origin": "https://test.mysupersite.com"
    },{
      "origin": "https://*.mysupersite.com" 
    }
  ],
  "background_color": "black",
  "description": "Do super things",
  "icons": [
    {
      "src": "/imgs/PWA-icon-512.png",
      "type": "image/png",
      "sizes": "512x512"
    },
    {
      "src": "/imgs/PWA-icon-192.png",
      "type": "image/png",
      "sizes": "192x192"
    }
 ]
 
}

If my PWA installs fine (which it does), should putting https://test.mysupersite.com?book=GGGGG in a Chrome browser on an Android phone open the installed PWA?

I've also tried putting https://test.mysupersite.com (no query string) in the browser, but it also doesn't work.

Thank you for your time and help.

答案1

得分: 1

  1. 确保您已启用#enable-desktop-pwas-url-handling标志。

  2. 此API仅适用于在浏览器之外打开的链接,比如在消息应用程序中。 当您在浏览器中输入URL时,它不会起作用。引用文档中的描述:

    在浏览器选项卡中启动的导航不受此提案处理。

英文:
  1. Make sure you enabled the #enable-desktop-pwas-url-handling flag

  2. This API only works with links opened outside of the browser, like in messaging apps. It won't work when you enter the URL into the browser. Quoting the docs,
    > Navigations that start in a browser tab are not handled by this proposal

huangapple
  • 本文由 发表于 2023年4月4日 15:57:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/75926848.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定