forked from Jack477/electron-discord-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
notify.js
24 lines (21 loc) · 896 Bytes
/
notify.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
Based on GyozaGuy's JS script (that seems to be based on
electron-notifcation-shim script):
This JS will catch the errors, send the info back about that throught the
icp API and show the notification again. Unlike the GyozaGuy's script, mine
will revert icon to the normal as soon as the user will check the window
(as soon as the window will be focused).
*/
const ipc = require('electron').ipcRenderer
var NativeNotification = Notification
Notification = function(title, options) {
var notification = new NativeNotification(title, options)
ipc.send('receive-notification')
notification.on('click', () => {
ipc.send('notification-clicked')
})
return notification
}
Notification.prototype = NativeNotification.prototype
Notification.permission = NativeNotification.permission
Notification.requestPermission = NativeNotification.requestPermission.bind(Notification)