javascriptgoogle-chromegoogle-chrome-extensionalarms

Chrome extension API for alarms has method clear that is not working as per documentation


Chrome version is 33.0.1750.154 m.

As per the documentation at http://developer.chrome.com/extensions/alarms#method-clear, the signature of clear method is: chrome.alarms.clear(string name, function callback).

I have an alarm in my extension which is still under development:

chrome.alarms.get('refreshForNotification', function(alarm){
    console.log('>>>' + JSON.stringify(alarm));
});
>>>{"name":"refreshForNotification","periodInMinutes":2,"scheduledTime":1395892890429.581} 

Now, when I try to clear this alarm with:

chrome.alarms.clear('refreshForNotification', function(wasCleared){
    console.log('>>> wasCleared: ' + wasCleared);
});

I am getting the below error:

Error: Invocation of form alarms.clear(string, function) doesn't match definition alarms.clear(optional string name)
 message: "Invocation of form alarms.clear(string, function) doesn't match definition alarms.clear(optional string name)"

Can someone please guide/point me what is going wrong here? The alarms api is stable from chrome 22 as per documentation. If my code is not wrong, then either documentation is old or documentation is too new and current behaviour on my chrome will change in future.

Any hints/help will be useful.

Thanks


Solution

  • The optional callback of chrome.alarms.clear was added last week in http://crrev.com/258526 (Chrome 35.0.1903.0+). The online documentation shows the available features for the latest (dev) version, not the stable version.

    Chrome 35 is currently available on the developer channel, so if you really want to use this feature, then you can install Chrome from here.