docs: Adds Desktop notifications Fiddle example (#20525)
* docs: Adds Desktop notifications Fiddle example * Update index.html Removed the classes
This commit is contained in:
parent
b563cd1235
commit
e5ba6c5406
3 changed files with 152 additions and 0 deletions
29
docs/fiddles/native-ui/notifications/renderer.js
Normal file
29
docs/fiddles/native-ui/notifications/renderer.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
const basicNotification = {
|
||||
title: 'Basic Notification',
|
||||
body: 'Short message part'
|
||||
}
|
||||
|
||||
const notification = {
|
||||
title: 'Notification with image',
|
||||
body: 'Short message plus a custom image',
|
||||
icon: 'https://via.placeholder.com/150'
|
||||
}
|
||||
|
||||
const basicNotificationButton = document.getElementById('basic-noti')
|
||||
const notificationButton = document.getElementById('advanced-noti')
|
||||
|
||||
notificationButton.addEventListener('click', () => {
|
||||
const myNotification = new window.Notification(notification.title, notification)
|
||||
|
||||
myNotification.onclick = () => {
|
||||
console.log('Notification clicked')
|
||||
}
|
||||
})
|
||||
|
||||
basicNotificationButton.addEventListener('click', () => {
|
||||
const myNotification = new window.Notification(basicNotification.title, basicNotification)
|
||||
|
||||
myNotification.onclick = () => {
|
||||
console.log('Notification clicked')
|
||||
}
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue