You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We currently able to receive web desktop notifications successfully and would like to know if it is possible and how to prevent web notifications from showing when the tab being viewed by the user is our site.
here is our current implementation in our react web app, in particular our attempt to not show the notification if the user is currently looking at our site.
useEffect(() => {
function foregroundWillDisplayListener (event) {
console.log(event);
//dont show notification if tab is currently being viewed
if (document.visibilityState === 'visible') {
return event.preventDefault();
}
}
OneSignalDeferred.push(function () {
OneSignal.Notifications.addEventListener("foregroundWillDisplay", foregroundWillDisplayListener);
});
}, []);
looking at foregroundWillDisplayListener event param I saw there are 2 params:
notification
preventDefault - when call the prevent default function we are getting this error:
Error: Browser does not support preventing display.
at Object.preventDefault (ServiceWorkerManager.js:168:27)
your time and assistance is highly appreciated.
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
How can we help?
We currently able to receive web desktop notifications successfully and would like to know if it is possible and how to prevent web notifications from showing when the tab being viewed by the user is our site.
here is our current implementation in our react web app, in particular our attempt to not show the notification if the user is currently looking at our site.
looking at foregroundWillDisplayListener event param I saw there are 2 params:
your time and assistance is highly appreciated.
Code of Conduct
The text was updated successfully, but these errors were encountered: