I want to open a pop up just like hangout using a chrome extension. I would like to do it programmatically like when a notification is fired. How is this possible? My code bellow works only when the extension is open. I would like for it to somehow listen for push notifications from pub-nub in the background and fire when a notification is received.
var listenForIncomingCalls = {
init: function () {
var pubnub = PUBNUB.init({
subscribe_key: 'xxxxxxxxxx',
publish_key: 'xxxxxxxxxx',
ssl: true
});
pubnub.subscribe({
channel: 'test_incoming_calls',
message: function (m) {
console.log(m)
chrome.windows.create({ url: 'https://mobile.twitter.com/', type: 'panel' });
}
});
}
};
// Run our kitten generation script as soon as the document's DOM is ready.
document.addEventListener('DOMContentLoaded', function () {
listenForIncomingCalls.init();
});