Detect if pwa has been added on desktop

Asked

Viewed 104 times

0

I am developing a website, using the concepts of PWA, for management. My intention is to allow the user to add it to the Work area.

From the moment he does that, I intend to hide a div <div class="div-resouces"> ... </div> of my passion. My doubt is how to identify if my web application was started from the home screen?

Here’s the manifest I’ll use:

inserir a descrição da imagem aqui

1 answer

1

If you want to detect opening by PWA could try this code in javascript that tries to detect if the site was opened in standalone mode.

function isRunningStandalone() {
    return (window.matchMedia('(display-mode: standalone)').matches);
}
...
if (isRunningStandalone()) {
   /* código que sera executado se o site estiver em modo standalone */
}

There are other techniques, check if you can solve the problem with the code I passed otherwise take a look at this material.

PWA Detect

In addition there is still a page in the google documentation to try to solve the problem can refer here Google PWA Detect

Browser other questions tagged

You are not signed in. Login or sign up in order to post.