I'm developing a chrome extension and i'm currently making use of the chrome.notifications API. The behaviour i need, is to have each notification have a specific and possibly different url to open on click.
With the chrome rich notifications i can create a notification via chrome.notifications.create(string notificationId, NotificationOptions options, function callback)
but the Options parameter doesn't allow me to send in extra information, like the url i want it to open.
What's the best way to do this?
I could use the chrome.notifications.onClicked.addListener(function(string notificationId) {...})
function with the notificationId and find out what the url is, but either i make another call to the server to figure it out (which i want to avoid) or i could probably store it in the local storage, but the easier way would be just to create the notification with that information when i receive it from the server, instead of storing it or getting it again from the server only when the click happens.
I could use the Html5 Notifications, and do something like this:
var notification = new Notification('Notification title', {
icon: 'http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png',
body: "Hey there! You've been notified!",
});
notification.onclick = function () {
window.open("http://stackoverflow.com/a/13328397/1269037");
but i would lose the RichNotification features and i'm also trying to avoid going that way.
Is there a simpler or better way?
Cheers