I want show release notes (open new tab with my site or webkit notification) when my extension auto updated. How I can do this? Please help me.
3 Answers
You can save your extension version number in localStorage and check on extension startup if current extension version matches the one that is written in localStorage, if it doesn't it has been updated and you can open new tab.
background page:
window.addEventListener("load", function()
{
var ver = "1.0.0";
if (localStorage.ver !== ver)
{
if (localStorage.ver)
{
// it was updated
chrome.tabs.create({url:"YOUR_URL"});
}
localStorage.ver = ver;
}
}, false);
While this question is nearly 1 year old, future readers might be interested in a better way.
chrome.runtime.onInstalled
handles the version check for you, thus allowing you just focus on what action should happen. You could show a notification with an onclick event instead of always opening a new tab.
There is also an event, onUpdateAvailable
, should you require some processing before the new version is auto-installed.
On Update Event
chrome.runtime.onUpdateAvailable.addListener(function(details) {
console.log("updating to version " + details.version);
chrome.runtime.reload();
});
Check manually that Update is available or not
chrome.runtime.requestUpdateCheck(function(status) {
if (status == "update_available") {
console.log("update available...");
}
else if (status == "no_update") {
console.log("no update found");
}
else if (status == "throttled") {
console.log("Oops, wait for some time, you're asking too frequently ");
}
});