You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -327,13 +329,25 @@ class TwilioVoiceWeb extends MethodChannelTwilioVoice {
327
329
Future<bool?> requestMicAccess() async {
328
330
Logger.logLocalEvent("requesting mic permission");
329
331
try {
330
-
/// TODO(cybex-dev) - Check browser type, if it is Firefox (or Safari), use the permissions API else use the getUserMedia API
331
-
// final perm = await _webPermissionsDelegate?.request({"name": "microphone"});
332
-
// return (perm == "granted");
333
-
334
-
/// This dirty hack to get media stream. Request (to show permissions popup on Chrome and other browsers, then stop the stream to release the permission)
332
+
final isSafariOrFirefox =RegExp(r'^((?!chrome|android).)*safari|firefox', caseSensitive:false)
333
+
.hasMatch(_webNavigatorDelegate.userAgent);
334
+
335
+
if (isSafariOrFirefox && _webPermissionsDelegate !=null) {
336
+
try {
337
+
final result =await _webPermissionsDelegate!.request({"name":"microphone"});
338
+
if (result.state =="granted") returntrue;
339
+
} catch (e) {
340
+
printDebug("Failed to request microphone permission");
341
+
printDebug(e);
342
+
}
343
+
}
344
+
345
+
// Default approach for all browsers (and fallback for Safari & Firefox)
346
+
/// This dirty hack to get media stream. Request (to show permissions popup on Chrome
347
+
/// and other browsers, then stop the stream to release the permission)
335
348
/// TODO(cybex-dev) - check supported media streams
0 commit comments