runtime.onUpdateAvailable

Fired when an update is available but isn't installed immediately because the add-on is currently running.

If you do nothing, the update will be installed the next time the background page gets unloaded, if you want it to be installed sooner you can explicitly call runtime.reload. If your add-on is using a persistent background page, the background page never gets unloaded, so unless you call runtime.reload manually in response to this event the update will not get installed until the next time the browser itself restarts. If no handlers are listening for this event, and your add-on has a persistent background page, it behaves as if runtime.reload is called in response to this event.

Syntax

chrome.runtime.onUpdateAvailable.addListener(function(
  details // object
) {...})
chrome.runtime.onUpdateAvailable.removeListener(listener)
chrome.runtime.onUpdateAvailable.hasListener(listener)

This API is also available as browser.runtime.onUpdateAvailable.*.

Events have three functions:

addListener(callback)
Adds a listener to this event.
removeListener(listener)
Stop listening to this event. The listener argument is the listener to remove.
hasListener(listener)
Checks whether a listener is registered for this event. Returns true if it is listening, false otherwise.

addListener syntax

Parameters

callback

Function that will be called when this event occurs. The function will be passed the following arguments:

details
object. The manifest details of the available update.

Additional objects

details

The manifest details of the available update.

version
string. The version number of the available update.

Browser compatibility

Chrome Edge Firefox Firefox for Android Opera
Basic support Yes No No No 33

Examples

Listen for UpdateAvailable events:

function handleUpdateAvailable(details) {
  console.log(details.version);
}

chrome.runtime.onUpdateAvailable.addListener(handleUpdateAvailable);

Acknowledgements

This API is based on Chromium's chrome.runtime API. This documentation is derived from runtime.json in the Chromium code.

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

Document Tags and Contributors

 Contributors to this page: Makyen, chrisdavidmills, wbamberg
 Last updated by: Makyen,