Reputation: 140
I'm building a fast-paced browser-based online multiplayer game, where constant communication with the server (websockets) is necessary to receive updates on what the other players are doing. I would like to make this app as close to a progressive web app (PWA) as possible, where I can prompt mobile users to "install" the app to their home screen to make it easier to find and launch the app.
However, to get the PWA easy-to-install experience on chromium-based browsers it requires the app to have a service worker (https://web.dev/install-criteria/, https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Installable_PWAs). I guess this is to make sure the app can be used offline, but in my case it's unwanted since the app must be online and connected (via websocket).
Am I going about this the wrong way? What's the best way to provide an easy "install to home screen" experience for a must-be-online app that works on Android Chrome? E.g. something that pops up and asks them if they want to install, instead of directing users to manually open the menu in the browser and clicking the "Add to Home Screen" button. Thanks!
Upvotes: 2
Views: 3218
Reputation: 43753
Yes, you need a service worker. However, even though your game can only be played online, there are uses for it to improve your game's user experience.
The simplest possible thing is to put up a themed loading screen. A step beyond that is to make your UI for starting a game accessible through the service worker, so whatever buttons are there (character select, game mode, options…) are instantly available even if the connection to the server takes a second this time for whatever reason. Removing delays can make your app feel much better to use.
Beyond that, you could consider adding interesting offline functionality that players might like to use while they have no network connectivity. Some examples:
Upvotes: 4
Reputation: 131
Your user will only get the "install to home screen experience" if you have a service worker registered. This service worker can be very minimalistic. But it needs to be present and active. Working offline or online is not a criteria for PWA.
Upvotes: 3