Last active
August 29, 2015 13:57
-
-
Save jayeshcp/9612142 to your computer and use it in GitHub Desktop.
Show popup notification from Chrome Extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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