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
Several browsers support
beforeinstallpromptevent 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 eventsbeforeinstallpromptmight get triggered.You will listen for the
beforeinstallpromptevent. 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
promptmethod on the event and optionally check if they accepted the prompt.