Chrome.runtime.onSuspend.addListener not working

I have a chrome extension connected to a built-in messaging app. I need to do some cleanup when the chrome extension pauses. I'm trying to use chrome.runtime.onSuspend.addListener but it doesn't work. 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" });   
        });
    }

      

+1


source to share





All Articles