I have two different functions that creates a chrome.notification and I would like the onclick actions to be separate as well. When I browse through the chrome extension API, there isn't a mention of how to handle this situation.
Here is the code I have in my background.js
chrome.notifications.onClicked.addListener(function(event){
chrome.tabs.create({url: 'details.html?id=' + event});
});
Assign a different id to each notification and check that id in the listener function:
chrome.notifications.onClicked.addListener(function(notifId){
if (notifId == "notification_1") {
//handle notification 1 being clicked
}
if (notifId == "notification_2") {
//handle notification 2 being clicked
}
//etc.
});
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments