chrome.runtime.onInstalled.addListener doesn't work

3,832 views
Skip to first unread message

Andrew Ste

unread,
Mar 12, 2013, 12:56:42 PM3/12/13
to chromium-...@chromium.org
When i'm trying in my extension to detect install or update event, nothing happens.

I'm doing like this:

// Check whether new version is installed
chrome.runtime.onInstalled.addListener(function(details){
    if(details.reason == "install"){
        console.log("This is a first install!");
    }else if(details.reason == "update"){
        var thisVersion = chrome.runtime.getManifest().version;
        console.log("Updated from " + details.previousVersion + " to " + thisVersion +" + !");
    }
});

But i didn't see any console.log messages in my background page.
I'm tried to reloading page with extensions when extension is installed (update action trigger?), installing packaged crx, nothing works. 
Chrome Version 25.0.1364.160 m

Maybe, i need to set up some permissions? How can i see, that this event is fired?

Andrew Ste

unread,
Mar 12, 2013, 12:58:54 PM3/12/13
to chromium-...@chromium.org
Forget to say, - installing by dragging extension into chrome://extensions/ page, not from Web Store.

Andrew Ste

unread,
Mar 12, 2013, 1:07:13 PM3/12/13
to chromium-...@chromium.org
i found the strange, but working solution.

This is example of my background file, named daemon.js and called from background.html page

require.config({
  baseUrl: '/js' 
});


require([
    "background"
  ], function() { 
      
  });

chrome.runtime.onInstalled.addListener(function(details){
    console.log(details);
});

As you see, it uses require.js and calling background.js file. It's a point of enter.
If i place chrome.runtime.onInstalled INSIDE background.js, - it will not work.
But when i place chrome.runtime.onInstalled like this, directly in daemon.js file, - it works.
Why this happens, can someone explain?


2013/3/12 Andrew Ste <stag...@gmail.com>
--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en-US.
For more options, visit https://groups.google.com/a/chromium.org/groups/opt_out.
 
 

Abraham Williams

unread,
Mar 12, 2013, 1:08:13 PM3/12/13
to Andrew Ste, Chromium-extensions
Try using alert instead. You will only see console.log when the background script console is open and it won't be open when you install.


Abraham
--
This email is: [ ] shareable [x] ask first [ ] private


--

Alvin Wong

unread,
Mar 24, 2013, 11:17:01 AM3/24/13
to chromium-...@chromium.org
Or use Desktop Notification (example)

Andrew Ste於 2013年3月13日星期三UTC+8上午12時56分42秒寫道:
Reply all
Reply to author
Forward
0 new messages