[英]Twilio in chrome extension - user denied access to microphone
I am new to chrome extension. 我是chrome扩展的新手。 Is there a possibility of providing a microphone access permission to chrome extension by manual (javascript) or using manifest configurations.
是否可以通过手册(javascript)或使用清单配置来提供对chrome扩展程序的麦克风访问权限。
I have included twilio successfully by downloading the twilio.js and changed the protocol to "https" for using in background.html of chrome extension. 我已经通过下载twilio.js成功地包含了twilio,并将协议更改为“ https”,以便在chrome扩展的background.html中使用。
Manifest.js fields are follows : Manifest.js字段如下:
"permissions":["http://*/*", "https://*/*", "*://mail.google.com/*", "storage", "unlimitedStorage", "contextMenus", "cookies", "tabs", "notifications", "activeTab", "background","identity", "*://*.twilio.com/*"],
"content_security_policy": "script-src 'self' 'unsafe-eval' https://apis.google.com https://*.twilio.com; object-src 'self' https://*.twilio.com",
Now,when extension made/receive a call using twilio and accepts the connection. 现在,当分机使用twilio拨打/接听电话并接受连接时。 It throws error from Twilio.Device.error method as follows
它从Twilio.Device.error方法引发错误,如下所示
error.message is **User denied access to microphone**.
Could anyone please help me to resolve this error ? 谁能帮我解决这个错误?
I have found an work-around way to enable twilio in the chrome extension's background page. 我在chrome扩展程序的背景页面中找到了一种启用twilio的变通方法。
First time, when we install the extension into chrome app. 第一次,当我们将扩展程序安装到chrome应用程序中时。 Just create a new tab with dummy html from the extension directory as below code snippet and make a test call.
只需从扩展目录中使用虚拟html创建一个新标签,如下代码片段所示,然后进行测试调用。
chrome.tabs.create({'url': chrome.extension.getURL('/telephony.html')}, function(tab) {
console.debug("Telephony Tab details are - ",tab);
});
It will prompt the user for microphone access and provide allow permission. 它将提示用户访问麦克风并提供允许权限。 Once call connected, send a message to background page and setup the Twilio in background.
接通电话后,将消息发送到后台页面并在后台设置Twilio。 Form the next time you can able to receive the calls in the background.
下次您可以在后台接收来电。
I'm a developer evangelist for Twilio. 我是Twilio的开发人员。
I haven't tried anything in Chrome extensions with Twilio Client just yet, but I took a look at the permissions. 到目前为止,我还没有使用Twilio Client在Chrome扩展程序中进行任何尝试,但是我研究了这些权限。 It looks to me like you need to include the
audioCapture
permission in order to get access to the microphone via getUserMedia
, which is what Client uses. 在我看来,您需要包含
audioCapture
权限,才能通过客户端使用的getUserMedia
访问麦克风。
I was looking up the available permissions here: https://developer.chrome.com/apps/declare_permissions 我在这里查找可用的权限: https : //developer.chrome.com/apps/declare_permissions
I hope that helps, let me know if I can help any further. 希望对您有所帮助,让我知道是否可以提供进一步的帮助。
UPDATE: 更新:
As discussed, that is the page for Chrome packaged apps, not extensions. 如前所述,这是Chrome打包应用程序的页面,而不是扩展程序的页面。
The top answer to this question suggests making a call to getUserMedia
in an options page for the extension. 该问题的最佳答案建议在扩展的选项页中调用
getUserMedia
。 Otherwise, there is a bug on Chrome open to add these permissions to extensions . 否则, Chrome浏览器会打开一个错误,以将这些权限添加到扩展程序中 。
finally I successfully use microphone with Chrome extension in a tricky way and with some error message but the Twilio functions still work(callout & recieve call). 最终,我成功地通过一个棘手的方式成功地将麦克风与Chrome扩展程序配合使用,并出现了一些错误消息,但Twilio功能仍然可以正常使用(标注和接收呼叫)。
Here is my experience, due to the Twilio js library will load external library which chrome extension not allowed, so I download the two library manually 这是我的经验,由于Twilio js库将加载不允许chrome扩展的外部库,因此我手动下载了这两个库
save these two js file to your project and load it in manifest by contentscript: 将这两个js文件保存到您的项目中,并通过contentscript将其加载到清单中:
"content_scripts": [
{
****
"js": [...,"lib/twilio.js","lib/twilio-lib.js",...],
***
}
],
then edit the first twilio.js; 然后编辑第一个twilio.js; comment the line62, line66 which intend to load a lib(the second, twilio-lib.js, we already include it, so it's useless)
评论第62行,第66行打算加载一个lib(第二个,twilio-lib.js,我们已经包含了它,所以它没有用)
then you can use Twilio.Device object in chrome extension, it will show many .mp3 not found message but doesn't block you use Twilio client functions 那么您可以在Chrome扩展程序中使用Twilio.Device对象,它将显示许多.mp3找不到消息,但不会阻止您使用Twilio客户端功能
and I also try to load the js in background page, but the microphone always shutdown even I get the permission. 并且我也尝试在后台页面中加载js,但是即使获得许可,麦克风也会始终关闭。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.