Skip to content

Commit 5e033cb

Browse files
authored
docs: Update notifications (main) docs (electron#29268)
* remove version info from index.html page * remove nodeIntegration * format code and update readme * add note to user in index.html
1 parent 36bca32 commit 5e033cb

File tree

3 files changed

+11
-20
lines changed

3 files changed

+11
-20
lines changed

docs/fiddles/features/notifications/main/index.html

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
</head>
88
<body>
99
<h1>Hello World!</h1>
10-
<p>
11-
We are using node <script>document.write(process.versions.node)</script>,
12-
Chrome <script>document.write(process.versions.chrome)</script>,
13-
and Electron <script>document.write(process.versions.electron)</script>.
14-
</p>
10+
<p>After launching this application, you should see the system notification.</p>
1511
</body>
1612
</html>

docs/fiddles/features/notifications/main/main.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,17 @@ const { app, BrowserWindow, Notification } = require('electron')
33
function createWindow () {
44
const win = new BrowserWindow({
55
width: 800,
6-
height: 600,
7-
webPreferences: {
8-
nodeIntegration: true
9-
}
6+
height: 600
107
})
118

129
win.loadFile('index.html')
1310
}
1411

12+
const NOTIFICATION_TITLE = 'Basic Notification'
13+
const NOTIFICATION_BODY = 'Notification from the Main process'
14+
1515
function showNotification () {
16-
const notification = {
17-
title: 'Basic Notification',
18-
body: 'Notification from the Main process'
19-
}
20-
new Notification(notification).show()
16+
new Notification({ title: NOTIFICATION_TITLE, body: NOTIFICATION_BODY }).show()
2117
}
2218

2319
app.whenReady().then(createWindow).then(showNotification)

docs/tutorial/notifications.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,17 @@ Starting with a working application from the
5555
```javascript fiddle='docs/fiddles/features/notifications/main'
5656
const { Notification } = require('electron')
5757

58+
const NOTIFICATION_TITLE = 'Basic Notification'
59+
const NOTIFICATION_BODY = 'Notification from the Main process'
60+
5861
function showNotification () {
59-
const notification = {
60-
title: 'Basic Notification',
61-
body: 'Notification from the Main process'
62-
}
63-
new Notification(notification).show()
62+
new Notification({ title: NOTIFICATION_TITLE, body: NOTIFICATION_BODY }).show()
6463
}
6564

6665
app.whenReady().then(createWindow).then(showNotification)
6766
```
6867

69-
After launching the Electron application, you should see the notification:
68+
After launching the Electron application, you should see the system notification:
7069

7170
![Notification in the Main process](../images/notification-main.png)
7271

0 commit comments

Comments
 (0)