web-push


Do I need to show a notification in response to a push notification if my site is foreground and focused?


I'm building a Progressive Web App that uses Web Push Notifications and want to avoid showing notifications to users on either desktop or mobile that are already currently looking at my site.
I'm aware that my site must always show a notification when a push event is handled, but can I skip showing a notification if my site is open, in the foregoing and has focus?
Also is it possible to determine the above things when deciding whether to show a notification?
It turns out you don't have to show a notification if your site is visible.
This can be implemented as follows:
self.addEventListener('push', event => {
return clients.matchAll({ type: 'window' }).then(clients => {
for (let i = 0; i < clients.length; ++i) {
if (clients[i].visibilityState === 'visible')
return; // there is a visible window
}
// continue with showing a notification
});
});

Related Links

My Pushpad Sender does not send any more notifications
Pushpad or Web push notification how to custom dialog message
What is VAPID and why is it useful?
How can I test pushsubscriptionchange event-handling code?
How should I handle the pushsubscriptionchange event?
How can I hide notifications my site is displaying if it is focused and brought to the foreground?
Do I need to show a notification in response to a push notification if my site is foreground and focused?
Getting customized message from GCM using Web push notifications
Firefox Push API - AbortError: Error retrieving push subscription

Categories

HOME
events
jms
selenium-builder
devexpress
dry
ews
braintree
whmcs
video-streaming
angular-meteor
graphql-js
mailing-list
match
phpstorm-2017.1
game-maker
documentum
business-intelligence
freertos
django-rq
web-deployment
xsl-fo
http-authentication
spring-shell
spyder
activeadmin
tableview
maven-surefire-plugin
liferay-6.2
miniprofiler
amazon-cloudtrail
monitor
matlab-app-designer
reporting
love2d
jade4j
cargo
rdp
permission-denied
flume-twitter
head.js
google-news
email-forwarding
sesame
case-when
swiperefreshlayout
dymola
front-camera
gawk
haraka
android-sdcard
maximize
vimperator
as3-api
voronoi
wikimedia-commons
ajax4jsf
ui4j
outlook.com
http.client
mixins
360-degrees
replicaset
darwin
org-babel
ssmtp
incron
jolie
hp-idol-ondemand
adhoc-polymorphism
configurable-product
inequality
inputbox
mfmessagecomposeview
stripe.net
gpu-programming
meteorite
vlab
acitree
iirf
indesign-server
unicoins
ofstream
2d-vector
playorm
motodev-studio
vows
winsxs
printqueue
jdownloader
uninstaller
wmd-editor
main-method
accumulator
datagridcolumn
gui-designer
isapi-redirect

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App