Re: [manifest] Allow developers to detect when the user has added the site to their home screen (or equivalent) (#417)

Today my web app uses the Chrome prompt, but it also should support Safari in iOS home screen, we created a custom modal telling the users they can save the web app to their home screen.. The problem we had is that there's no way to remove this modal once the users has added the web app to their home screen.

This isn't a problem with analytics purposes but implementation.

On Safari we have a non-standard `window.navigator.standalone` which is terrible, but other informations on navigator would be appreciated to answer these question.

1. Does the user has this web app on the their home screen?
```js
if (!('AddToHomeScreen' in window.navigator)) {
  // browser doesn't support it
  return
}

if (window.navigator.AddToHomeScreen) {
  // icon in the home screen, based on this you can take lots of decisions
} else {
  // app isn't in the home screen
  // And isn't Chrome, what about showing the user how to add this to its home screen?
}
```

The issue I'd have with @marcoscaceres https://github.com/w3c/manifest/issues/417#issuecomment-164981366 mediaMatch solution is that I could use on manifest.json `"display": "browser"`, not only `"display":"standalone"`.

The issue I'd have with only a `installed` events, is that is will be fired once, then later I'll need to save it to my localStorage, or make some other workout to know if the has installed it or not 

I'd suggest something like this

```js
window.addEventListener('addedToHomeScreen', handleAddedToHomeScreen)
window.navigator.addedToHomeScreen // Boolean // Easy to check for browser support

function handleAddedToHomeScreen() {
  // Send analytics convertion, this user seems to love our web app
}
```

---
Reply to this email directly or view it on GitHub:
https://github.com/w3c/manifest/issues/417#issuecomment-168700461

Received on Monday, 4 January 2016 15:04:50 UTC