I have a Chrome extension communicating with my Windows application by Native Messaging. However there is case that user installs extension, but doesn't have application installed. In this case there is a runtime error (Unchecked runtime.lastError: Specified native messaging host not found.) appeared in my extension in chrome://extensions list when extension calls chrome.runtime.connectNative(). Is there any way to avoid this error message?
-
It doesn't exist.Norio Yamamoto– Norio Yamamoto2023-01-26 10:11:59 +00:00Commented Jan 26, 2023 at 10:11
-
1As the error message says you need to check chrome.runtime.lastError in the callback of connectNative.woxxom– woxxom2023-01-26 10:33:55 +00:00Commented Jan 26, 2023 at 10:33
-
but according to developer.chrome.com/docs/extensions/reference/runtime/…, it does not have a callbackSantK– SantK2023-01-26 14:04:47 +00:00Commented Jan 26, 2023 at 14:04
-
2@SantK - You are correct, chrome.runtime.connectNative doesn't have a callback. But it always returns a Port object, even if there's an error. And you can attach callbacks to the port's onDisconnect and onMessage events. An error during connection causes an onDisconnect event.Thomas Mueller– Thomas Mueller2023-01-26 15:18:57 +00:00Commented Jan 26, 2023 at 15:18
-
Example: How do I find out if connectNative failed or succeededwoxxom– woxxom2023-01-26 20:57:31 +00:00Commented Jan 26, 2023 at 20:57
Add a comment
|