问题描述
如何模仿Google chrome使用的添加到主屏幕功能.单击该快捷方式后,它将以全屏方式打开.
How to mimic the add to home screen functionality used by google chrome. When clicked that shortcut, it opens in fullscreen.
我尝试在Android中添加快捷方式,但找不到全屏打开的内容,但我认为Flipkart能够做到.有什么方法可以像chrome一样.
I tried in Android to add a shortcut, but could not find anything to open in full screen, but I think Flipkart was able to do it. Is there any method to do like chrome does.
推荐答案
当您在Chrome浏览器中单击添加到主屏幕"时,会发生两种情况.
When you click on "Add to Home screen" in chrome, two tings happens.
1)如果您的网站符合最低 PWA标准(有效Manifest.json,服务人员,通过具有有效证书的HTTPS进行服务)-Chrome使用WebAPK组件(它是Chrome浏览器本身的一部分)来创建.APK文件并对其进行动态签名,然后将其安装在手机中,例如已安装的应用程序从一家游戏商店.甚至该应用程序的信息也会显示该应用程序是从Play商店安装的(尽管它可能不完全是Google,但我估计稍后可能会重新命名)并由Google签名.
1) If your site meets minimum PWA criteria (valid Manifest.json, service worker, served though HTTPS with a valid certificate)- Chrome uses WebAPK component which is part of Chrome browser itself to create a .APK file and sign it on the fly and install it in your phone, like a app installed from a play store. Even the app info will show the app is installed from Play store(though its not exactly, Google may rephrase it later I guess) and signed by Google.
如果要模仿APK生成部分,当前无法使用.您可以使用ES文件资源管理器等文件资源管理器工具提取此.apk文件,然后将其用于移植到其他手机(不建议用于一般公共发行,因为您可能不知道用户是否支持Chrome版本)
If you want to mimic the APK generation part, there is no way currently. You can extract this .apk file using file explorer tools like ES file explorer and use it to port to other phones though(not recommended for general public distribution as you may not know if the user have supported version of Chrome)
2)如果您的应用不符合PWA标准(请使用Chrome渐进式Web应用的Lighthouse审核来查看您的应用是否符合安装到主屏幕的条件),当您尝试添加到主屏幕时,仍然会出现一个图标添加.但是,当您打开它时,它将在浏览器中使用地址栏打开.可以将其视为书签快捷方式.它是这样工作的.
2) If your app is not PWA compliant(use Chrome lighthouse audit for Progressive web app to see if your app is qualified to be installed to home screen), when you try to add to home screen, an icon will still be added. But when you open, it will open in the browser with the address-bar. Think of it like a bookmark shortcut. It works that way.
Flipkart的PWA兼容性最低,这使得Chrome可以生成.APK文件并像常规应用一样安装并在全屏模式下打开.
Flipkart has minimum PWA compliance, which makes Chrome to generate .APK file and install it like a regular app and open in full screen.
您必须说明创建应用程序时使用的所有PWA组件,您的应用程序在灯塔审核中通过的标准,尝试添加到主屏幕并打开它时发生的情况,以便我们进一步帮助
更新:以下是您网站的灯塔审核报告.在失败的清单中,manifest.json没有有效的start_url是您需要解决的问题,以获取安装横幅并将其作为应用添加到将以全屏模式打开的主屏幕.
Update: Below is the lighthouse audit report for your site. Out of failed ones, manifest.json not having a valid start_url is the issue that you need to solve to get install banner and add it as an app to home screen which will open in full screen.
我可以在 https://locoshift.com/manifest.json 上看到您的清单start_url为
I could see your manifest at https://locoshift.com/manifest.json, with start_url as
"start_url": "https://locoshift.com",
尝试将其更改为,以便可以从此处定位清单.我将"/index.html"作为start_url,对我来说也是如此.
try changing it to, so it can locate manifest from there. I have "/index.html" as the start_url and that works as well for me.
"start_url": "https://locoshift.com/",
您可以添加主题颜色清单条目和meta标签来解决它报告的其他两个问题.但是它们只是表面上的,不会引起您要解决的问题.
You can add theme color manifest entry and meta tag to solve other two issues it reports. But they are cosmetic and not causing the issue that you are trying to solve.
这篇关于如何从Android应用程序以编程方式向主屏幕添加WebApp快捷方式,以全屏启动WebApp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!