-->

chrome.runtime.onSuspend.addListener没有发射(chrome.ru

2019-10-21 09:00发布

我有连接到本地消息应用程序中的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" });   
        });
    }
文章来源: chrome.runtime.onSuspend.addListener not firing