1

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.

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

});
ecorvo
  • 3,559
  • 4
  • 24
  • 35
  • possible duplicate of [How to build an chrome extension like Google Hangouts](http://stackoverflow.com/questions/9487446/how-to-build-an-chrome-extension-like-google-hangouts) – Xan Sep 04 '14 at 21:23
  • 1
    In short: this is an option not widely enabled yet (requires a flag or a command line argument) but Hangouts is expressly whitelisted to use it. – Xan Sep 04 '14 at 21:25
  • That helped. But is it possible to trigger this from a push notification? For example, right now in order for this to work I need to have the extension open. Can I open the panel without opening the extension see code bellow: – ecorvo Sep 04 '14 at 21:32
  • sorry for the formatting I added the code to the original question – ecorvo Sep 04 '14 at 21:35
  • Now it's completely unclear what you're asking. As I said, `type: "panel"` only works in Google's own Hangouts because it is allowed to use it, the rest will open normal popups. – Xan Sep 04 '14 at 21:40
  • 1
    It might be more widely available now. I've seen other extensions doing it since I posted that answer. – abraham Sep 04 '14 at 22:24
  • I was able to accomplish was I wanted. I needed a background.js file to run in the background and listen for the push notifications. – ecorvo Sep 05 '14 at 00:45
  • It is not widely available, I for one just send my users to enable the flag to access panels. – Daniel Herr Sep 05 '14 at 23:26

0 Answers0