dragonloverlord
dragonloverlord

Reputation: 442

How to alert user upon update of chrome app?

I have a chrome app that I am going to be updating and the update will break previous saves. Now I would like to alert the users of the app upon successful completion of the update. I do have an chrome api that I am trying to use which is:

chrome.runtime.onInstalled.addListener(function(){

});

Now I have read the chrome.runtime developer docs and it says that I can use:

chrome.runtime.onInstalled.addListener(function callback)

With a callback function of:

function(object details) {...};

The problem is that I can not figure out what exactly to do with the info as I have tried a couple of different set ups with this code but none work. any help with this issue would be appreciated

Please note that I am trying to display a window that would contain this message. Also my current code is in the background.js of my app although as said the code does not work.

Upvotes: 0

Views: 143

Answers (1)

Xan
Xan

Reputation: 77541

Documentation mentions one property of details:

reason

enum of "install", "update", "chrome_update", or "shared_module_update"

The reason that this event is being dispatched.

So your code needs to check that:

chrome.runtime.onInstalled.addListener(function(details){
  if(details.reason == "update") {
    // Inform the user of the sad news
  }
});

Upvotes: 2

Related Questions