相关疑难解决方法(0)

native-app和chrome-extension之间的通信

我有一个用c ++和chrome扩展编写的本机应用程序.

我正在使用"chrome native messaging"在它们之间进行通信.

Native-App代码:

int main(int argc, char* argv[]) {
 unsigned int a, c, i, t=0;
 std::string inp;  do {
 inp="";
 t=0;
 // Sum the first 4 chars from stdin (the length of the message passed).
  for (i = 0; i <= 3; i++) {
    t += getchar();
  }

  // Loop getchar to pull in the message until we reach the total
  //  length provided.
  for (i=0; i < t; i++) {
    c = getchar();
    inp += c; …
Run Code Online (Sandbox Code Playgroud)

c c++ google-chrome google-chrome-extension chrome-native-messaging

7
推荐指数
1
解决办法
4354
查看次数

Chrome扩展NativeMessaging'connectNative'未定义

我正在尝试使用runtime.connectNative和postMessage实现chrome扩展.我正在关注chrome文档,下载了我尝试运行的本机消息传递示例,没有任何更改,而本机宿主应用程序的代码可以在这里找到.

但是,我收到错误:Uncaught TypeError:无法读取未定义的属性'connectNative'.

该错误是从javascript扩展文件触发的,在此行中:
port = chrome.runtime.connectNative(hostName);

正在从清单加载扩展名,如下所示:

"app": {
   "launch": {
      "local_path": "main.html"
   }
}
Run Code Online (Sandbox Code Playgroud)

有什么想法可以解决问题吗?

Chrome版本34,在Windows 7,8.1上测试过

javascript google-chrome-extension chrome-native-messaging

4
推荐指数
1
解决办法
4609
查看次数