Skip to content

Instantly share code, notes, and snippets.

@jayeshcp
Last active August 29, 2015 13:57
Show Gist options
  • Save jayeshcp/9612142 to your computer and use it in GitHub Desktop.
Save jayeshcp/9612142 to your computer and use it in GitHub Desktop.
Show popup notification from Chrome Extension
var options = {
type: 'basic',
iconUrl: 'images/app_icon.png',
title: chrome.i18n.getMessage("appName"),
message: chrome.i18n.getMessage("notif_message"), //You haven't made entry to your diary. Want to finish now ?
buttons: [
{
title: chrome.i18n.getMessage("add_now")
}
]
};
var notifid = "1";
chrome.notifications.create(notifid, options, function(id) {console.log("notification shown");});
chrome.notifications.onButtonClicked.addListener(function(notificationId, buttonIndex) {
if(notificationId === notifid) {
if (buttonIndex === 0) {
console.log("Add button clicked");
chrome.notifications.clear(notificationId, function() {});
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment