Search code examples
javascripthtmlcssfont-awesomehtml5-notifications

Can I display font-awesome icons in html5 notifications


I was trying to display desktop notifications on my website.As per this documentation here, I can provide a URL to the icon image.But my website is using font awesome icons, therefore I do not have a URL for icons.Any help or alternatives will be appreciated

function spawnNotification(theBody,theIcon,theTitle) {
  var options = {
      body: theBody,
      icon: theIcon //this should be a URL can I provide an icon class of a text content?
  }
  var n = new Notification(theTitle,options);
}

Solution

  • Fontawesome icons does come in png, you can directly use a URL to the icon image. You can host your images on your server

    function spawnNotification(theBody,theIcon,theTitle) {
      var options = {
          body: theBody,
          icon: 'http://yourdomain.com/icons/icon.png'
      }
      var n = new Notification(theTitle,options);
    }
    

    For more info about the icons refer here