-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpreload.js
More file actions
27 lines (22 loc) · 737 Bytes
/
Copy pathpreload.js
File metadata and controls
27 lines (22 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('electronAPI', {
sendNotification: (title, body) => ipcRenderer.send('notify', { title, body })
});
window.addEventListener('DOMContentLoaded', () => {
function CustomNotification(title, options) {
ipcRenderer.send('notify', {
title: title,
body: options.body || ''
});
return {
onclick: null,
close: () => {}
};
}
CustomNotification.permission = 'granted';
CustomNotification.requestPermission = (cb) => {
if (cb) cb('granted');
return Promise.resolve('granted');
};
window.Notification = CustomNotification;
});