Google chrome extension Chrome扩展端口。当本机应用程序关闭时,未调用本机连接的onDisconnect侦听器

Google chrome extension Chrome扩展端口。当本机应用程序关闭时,未调用本机连接的onDisconnect侦听器,google-chrome-extension,Google Chrome Extension,在我的chrome扩展代码中,我正在建立与本机应用程序的本机连接,现在每当该本机应用程序关闭时,chrome扩展端口.onDisconnect侦听器不会被触发 有谁能帮助我实现这一目标吗 port = chrome.runtime.connectNative("host.name"); port.onMessage.addListener(function(data) {}); // Not getting fired when native app shuts down port.onDi

在我的chrome扩展代码中,我正在建立与本机应用程序的本机连接,现在每当该本机应用程序关闭时,chrome扩展
端口.onDisconnect
侦听器不会被触发

有谁能帮助我实现这一目标吗

port = chrome.runtime.connectNative("host.name");

port.onMessage.addListener(function(data) {});

// Not getting fired when native app shuts down
port.onDisconnect.addListener(function(event) {});

您是否按照中的说明设置了本机应用程序主机

除此之外,您还可以尝试通过调用port.disconnect()强制端口断开连接。
当本机应用程序关闭时,端口可能不一定断开连接。

是的,我已按照文档中的说明设置本机应用程序。我的要求是在本机应用程序关闭时在浏览器窗口(我的网站)上显示一个弹出窗口。在弹出窗口中,我需要要求用户“如果要使用此网站,请启动本机应用程序”