I have built a simple chrome application which has a background page that shows desktop notifications when a new article is available.
If a user clicks on the notifications when a browser window is open, then they are taken to the new article page and everything is right with the world.
If however the browser is closed when the notification is shown, then the href does not open the browser. I have also tried to capture the click and set a window.open, but that isn't working either.
As an aside, it would also be good if I could check to see if an instance of my app is already open and use that window/tab when the notification is clicked, but that's secondary to the first problem.
Any help would be great!
Thanks
Check if chrome window is open. if open the create in new tab else oepn new window.
chrome.windows.getCurrent(function(currentWindow) {
if (currentWindow != null) {
return chrome.tabs.create({
'url': url
});
} else {
return chrome.windows.create({
'url': url,
'focused': true
});
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With