Search code examples
google-chrome-extension

chrome.alarms returns undefined


Good morning, wizards.

I'm trying myself in writing an extension for chromium-browser. The version of chromium is 18.0.1025.151 (development build 130497 Linux) Built on Ubuntu 12.04, running on Ubuntu 12.10

My OS is ubuntu GNU/Linux 12.04.1 (LTS), 64bit.

The problem is: I cannot use chrome.alarms. I get 'undefined' when access this variable.

Part of my manifest.json:

  "background": {
      "scripts": ["background.js"]
    },
  "permissions": [
    "alarms",
    "tabs",
    "http://*/*"
  ],

Part of my background.js:

chrome.alarms.onAlarm.addListener(function(alarm) {
    if (! alarm.name.match ('/^extension47_.*/'))
        return;
    alert ('extension47 fired an alarm!');
});

What I get:

Uncaught TypeError: Cannot read property 'onAlarm' of undefined

at the line chrome.alarms.onAlarm.addListener.

When I go to the chromium console from the extensions page, auto-completion suggests me no chrome.alarms. Obviously, when I type there chrome.alarms, I really get undefined. Why so?..

I'm totally stuck, failed to find a solution anywhere on the Internet, what am I doing wrong?


Solution

  • You need at least Google Chrome 22.

    Availability:   Google Chrome 22
    

    http://developer.chrome.com/trunk/extensions/alarms.html