How can we catch webview notification informations?


#1

Hello everyone !

I’m using a webview in my electron app + node notifier for native notifications (which is better than native notification of electron).

When the website included in my webview generates push notifications, electron generates the same native ones.

So first: How to disable display of webview notifications ?
Core question: How to get the informations of this notification ? (like title, description, url on click…)

Thanks a lot !

ps: here is a website to test notifications http://www.bennish.net/web-notifications.html


#2

you can add a preloader to listen for notifications if you are using a webview to load the website.This might help you https://github.com/seriema/electron-notification-shim


#3

In case anyone needs help with this.

For just disabling notifications, you’ll need to override the notification object.

var Notification = function(){};
window.Notification = Notification;

This will disable the notifications.
To fetch the content of the notifications, you can override it such that the information is passed to the main process.

var Notification = function(title,ops){
// title is the title of the notifations, ops is the config object
ipcRenderer.sendToHost(//send the objects);
};
window.Notification = Notification;