chrome.runtime.onSuspend.addListener未触发

我有一个连接到本机消息传递应用程序的chrome扩展。 当chrome扩展暂停时,我需要做一些清理工作。 我正在尝试使用chrome.runtime.onSuspend.addListener,但它无法正常工作。 这是我的代码: –

的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" }); }); } 

Interesting Posts