自动创建网站快捷方式到移动屏幕的主页
我想在我的网站上创建一个按钮“将此网站保存到我的手机”。单击时将创建一个 URL 快捷方式(带有图标,外观与手机应用程序类似),并将放置在用户的移动设备主屏幕上。 单击手机上的此图标将打开用户默认的 Web 浏览器并加载网站。
我知道这个过程可以通过几次点击手动完成,例如在本教程中:https://www.turitop.com/blog/how-to-save-website-shortcuts-to-my-smartphone-android-ios-and-windows-mobile/ 但我想为我的用户自动执行此功能。
有什么办法可以做到这一点吗? 谢谢
I want to create a button on my website "Save this website to my phone." that when clicked will create a url shortcut (with icon, similar in appearance to a phone app) and will be placed onto the user's mobile device home screen.
Clicking this icon on the phone opens the users default web browser and loads the website.
I understand this process can be done manually with several clicks, such as in this tutorial: https://www.turitop.com/blog/how-to-save-website-shortcuts-to-my-smartphone-android-ios-and-windows-mobile/
but I want to automate this functionality for my users.
Is there any way that this can be done?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于满足可安装性要求。基本上,如果您有 manifest,用户就会与您的网站进行交互,并且 服务服务工作线程处理获取事件
beforeinstallprompt
可能会被触发。您将监听
beforeinstallprompt
事件。如果它被触发,您将保留对该事件的引用并显示您自己的“安装应用程序”UI。当用户单击自定义安装提示时,您可以调用事件的
prompt
方法,并可以选择检查他们是否接受提示。Several browsers support
beforeinstallprompt
event for sites that meet the installability requirements. Basically if you have a manifest, the user interacted with your site, and service service worker handles fetch eventsbeforeinstallprompt
might get triggered.You will listen for the
beforeinstallprompt
event. If it gets triggered you'll keep a reference to the event and show your own "install app" UI.When the user clicks on your custom install prompt you call the
prompt
method on the event and optionally check if they accepted the prompt.