add to home screen has one additional requirement: the content must be server over https.
create a manifest.json file in flarum root folder, insert to codes save it.
{
"short_name": "yoursite",
"name": "your site app name",
"icons": [
{
"src": "https://yoursite.com/icon-144x144.png",
"type": "image/png",
"sizes": "144x144"
}
],
"background_color": "#FFFFFF",
"theme_color": "#67BCFF",
"display": "standalone",
"start_url": "/?utm_source=homescreen"
create service-worker.js file in flarum root folder, insert to codes save it.
self.addEventListener('fetch', function(event) {});
go to /vendor/flarum/core/views/frontend/
open app.blade.php
add to code: <link rel="manifest" href="/manifest.json">
below the <head> tag.
add to code:
<script>
if ("serviceWorker" in navigator) {
window.addEventListener("load", function () {
navigator.serviceWorker.register("/service-worker.js");
});
}
</script>
above the </body> tag.
articles:
https://developers.google.com/web/fundamentals/app-install-banners/
https://codelabs.developers.google.com/codelabs/add-to-home-screen/