问题
I am having a chrome extension connected to native messaging application. I need to do some cleanup when the chrome extension suspends. I am trying to use chrome.runtime.onSuspend.addListener but it is not working. Here is my code : -
Manifest.json
"background": {"scripts": ["background.js"],
"persistent": false},
background.js
function Connect() {
console.log("Connected");
ext = chrome.runtime.connectNative('foxtrot');
chrome.runtime.onSuspend.addListener(function () {
ext.postMessage({ message: "clean and close" });
});
}
来源:https://stackoverflow.com/questions/27311204/chrome-runtime-onsuspend-addlistener-not-firing