如何使用Chrome扩展程序打开Goog​​le Hangouts等弹出窗口

时间:2014-09-04 21:06:30

标签: google-chrome google-chrome-extension

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

enter image description here

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();

});

0 个答案:

没有答案