我想像使用Chrome扩展程序的环聊一样打开弹出窗口。我希望以编程方式执行此操作,就像通知被触发一样。这怎么可能?我的代码仅在扩展程序打开时才起作用。我想以某种方式在后台监听来自pub-nub的推送通知,并在收到通知时触发。
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();
});