electron-windows-notifications
electron-windows-notifications copied to clipboard
Persistent notifcations
Hey guys,
Thanks for this awesome module! I played with this a bit on my Electron app, but the notifications I am getting aren't persistent and don't stay in the action center. (Not sure if I missed something)
Is there any way of making notifications persistent so that they only go away once the user removes it?
Thanks
Can you please share your code? The notifications should be persistent.
The code is pretty straight forward:
function sendNotification(type, title, content, img, icon, id) {
const template
const strings
if (type === "actionsImg"){
var notifTemplate = '<toast launch="launchApp"> <visual> <binding template="ToastGeneric"> <image placement="appLogoOverride" hint-crop="circle" src="' + icon + '"/> <text>' + title + '</text> <text>' + content + '</text> <image placement="hero" src="' + img + '"/> </binding> </visual> <actions> <action content="Like" arguments="like-' + id +'"/> <action content="Retweet" arguments="rt-' + id + '"/> </actions> </toast>';
} else if (type === "actions"){
var notifTemplate = '<toast launch="launchApp"> <visual> <binding template="ToastGeneric"> <image placement="appLogoOverride" hint-crop="circle" src="' + icon + '"/> <text>' + title + '</text> <text>' + content + '</text></binding> </visual> <actions> <action content="Like" arguments="like-' + id +'"/> <action content="Retweet" arguments="rt-' + id + '"/> </actions> </toast>';
}
let notification = new ToastNotification({
appId: "Tweeten",
template: notifTemplate,
strings: strings
})
// show notification
notification.show()
}