Detect if pwa was added to the desktop

0

I'm developing a website, using PWA concepts, for management. My intention is to allow the user to add it to the work area.

As soon as it does, I want to hide a% div of my page. My doubt is how to identify if my web application has started from the home screen?

Here's the manifest I'm going to use:

    
asked by anonymous 21.12.2017 / 15:48

1 answer

1

If you want to detect opening by PWA you 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 that I passed or 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 you can check here Google PWA detect

    
21.12.2017 / 16:09