Making it installable
This will be the first feature added to your PWA. We will start by creating a manifest object and passing it as a parameter to a new BF function pwaSetManifest
. In this example we added this code to a function in our onAppLoad
named action.
Next, as part of the onAppLoad
as well, we add a new action pwaCustomInstall
This new action has the options beforeinstallprompt
, which are actions that will run before the trapped prompt to install event triggered by the browser when it identifies the web app as installable. The example above shows one way of setting a state variable that we will use to show or hide a button to install the app.
So in this case, we need a key isInstalled
in our model.
In our example, once the install button is clicked on, a modal will prompt asking whether the user wants to install it.
The named action instalApp
above has the following code.
The action pwaPromptInstall
is the action that triggers the browser to prompt the user with the actual window that will install the app. This gives the flexibility to trigger this event from anywhere in your app, and customize it according to your needs.
The options onAccepted_actions
and onDismissed_actions
will run after the user click on Cancel
, Install
or close the browser’s prompt window.
Our modal looks like the image below.
By clicking on Install
, it will trigger the browser event that asks if the user wants to install the app, as shown on the image below.
After installing it, the user will be able to access your web app as a regular native app.
Last updated