I have a requirement to change text message on site while chrome native popup comes up to allow for getting chrome based GCM push notifications from the site. see screenshot.
As i know native popup only come first time while enable notification for the site. but if suppose somebody allow first time then disable from the site and then trying enable again it will not come up.
So i just need to add a check in code to know that work only when popup comes up. this native popup comes up while subscribing chrome GCM notification on this line of code:
navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) {
serviceWorkerRegistration.pushManager.subscribe({userVisibleOnly: true}).then(function(subscription) {
Thanks in advance.
You can use the Permissions API and query for status "prompt"
In particular you can do something like this:
navigator.permissions.query({name:'notifications'}).then(function(result) {
if (result.status == 'prompt') {
// At this point you know that once you call pushManager.subscribe the
// Dialog will be shown.
}
});
The MDN page for Permissions API has more details https://developer.mozilla.org/en-US/docs/Web/API/Permissions/query