在JS扩展中使用chrome.bluetooth.AddProfile拒绝权限

时间:2013-07-22 23:22:57

标签: javascript google-chrome-extension bluetooth google-chrome-app

我在OSX上运行Google Chrome Canary。

我正在尝试修改developer example for bluetooth application for Zephyr HXM bluetooth client以连接到Android应用程序,该应用程序通过蓝牙侦听套接字以获取特定的UUID。

开发示例使用的API与现在基于配置文件的Chrome的更高版本不一致。

当我尝试在Zephyr客户端的main.js中调用chrome.bluetooth.addProfile({uuid: kUUID}, console.log)时,我收到以下错误消息:

bluetooth.addProfile: Permission to add profile denied. 然后是Error in response to bluetooth.addProfile: TypeError: Illegal invocation

如何授予扩展权限以调用addProfile? manifest.json已经提供了蓝牙权限。

有没有办法在Chrome中全局禁用权限以进行测试?

感谢。

2 个答案:

答案 0 :(得分:3)

您需要在manifest.json中声明蓝牙权限:

"permissions": [
  {
    "bluetooth": [
      {
        uuid: '<Your UUID>'
      }
    ]
  }
  ...
]

答案 1 :(得分:0)

因为它需要是打包的应用程序而不是扩展程序。蓝牙不会使用扩展程序。