electron-windows-notifications icon indicating copy to clipboard operation
electron-windows-notifications copied to clipboard

Persistent notifcations

Open MehediH opened this issue 8 years ago • 2 comments

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

MehediH avatar Dec 11 '16 09:12 MehediH

Can you please share your code? The notifications should be persistent.

nadavbar avatar Dec 15 '16 14:12 nadavbar

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()
}

MehediH avatar Dec 15 '16 16:12 MehediH