Created
January 31, 2022 20:35
-
-
Save shershen08/50b266e3d116dfe77ac5dbfb8dfcf2a5 to your computer and use it in GitHub Desktop.
notification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const sendNotification = (text) => { | |
//https://developer.mozilla.org/en-US/docs/Web/API/Notification/Notification | |
let promise = Notification.requestPermission(); | |
// wait for permission | |
promise.then(data => { | |
const eventName = 'new message' | |
var options = { | |
body: text, | |
// icon: 'https://community.hackages.io/static/media/logo_h_cube.6d1c5012.svg' | |
} | |
new Notification(eventName, options); | |
// enable reading | |
if(settings.readMessages) { | |
readMsg(eventName) | |
readMsg(options.body) | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment