Skip to content

Instantly share code, notes, and snippets.

@shershen08
Created January 31, 2022 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shershen08/50b266e3d116dfe77ac5dbfb8dfcf2a5 to your computer and use it in GitHub Desktop.
Save shershen08/50b266e3d116dfe77ac5dbfb8dfcf2a5 to your computer and use it in GitHub Desktop.
notification
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