Search code examples
androidioswindowsshortcuthomescreen

Automatically save url as launchable app on smart devices


Firstly, I'm aware of how to save a web URL to a smart device as a user as is explained in these answers (usually by saving the tab from the browser). These take multiple steps and vary depending on device, thus requiring research which most vanilla users of smart devices do not do.

Create a Android launch icon for Website

Add to homescreen on mobile phone

My question is from the perspective of the app owner. The end goal is to let create a link on the web app allowing users "Create Homescreen icon" from 1 click. I suspect this is not possible as it would create a huge security risk to the devices allowing random unsafe URL'S to potentially try and create unlimited shortcuts but I'd like to ask nonetheless.

Answers such as these make a URL support app creation, however it leaves the task of creating the shortcut to the user instead of the URL.

"Add to homescreen" button in Android does not show website as a Web App

I hope my question is clear enough, if it is not I'm more than willing to elaborate.


Solution

  • Chrome on Android two new features 1) Web App Manifest that describes what should be launched from the home screen and how it should look on the homescreen, and 2) Chrome now has an beforeinstallprompt event that will trigger for Web apps that we think are app-like and can be installed to the homescreen.

    There are a number of criteria for the onbeforeinstallprompt event to fire.

    The event only fires if:

    • The site has a manifest, is on https and has a service worker. (this can be quite a stretch).
    • The user has engaged with the site multiple times (right now, twice within at least 5 minutes).
    • The user has not already added your site to the home-screen.

    If all you want to do is detect if you should display a banner to prompt the user to add your web-app to the homescreen then Chrome already has a solution for you.

    We also have a full range of samples on our samples site.