Add runtime microphone permission request for WebRTC calls
The RECORD_AUDIO permission was declared in the manifest but never requested at runtime, causing WebRTC to fail on Android 6+. Now requests microphone permission on app startup before initializing the WebView. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
import 'package:webview_flutter_android/webview_flutter_android.dart';
|
||||
import '../services/push_notification_service.dart';
|
||||
@@ -40,6 +41,15 @@ class _PhoneScreenState extends State<PhoneScreen> with WidgetsBindingObserver {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
_pushService = PushNotificationService();
|
||||
_requestPermissionsAndInit();
|
||||
}
|
||||
|
||||
Future<void> _requestPermissionsAndInit() async {
|
||||
// Request microphone permission before initializing WebView
|
||||
final micStatus = await Permission.microphone.request();
|
||||
if (micStatus.isDenied || micStatus.isPermanentlyDenied) {
|
||||
debugPrint('TWP: Microphone permission denied: $micStatus');
|
||||
}
|
||||
_initWebView();
|
||||
_initPush();
|
||||
}
|
||||
|
||||
@@ -336,6 +336,54 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.0"
|
||||
permission_handler:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: permission_handler
|
||||
sha256: "59adad729136f01ea9e35a48f5d1395e25cba6cea552249ddbe9cf950f5d7849"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "11.4.0"
|
||||
permission_handler_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: permission_handler_android
|
||||
sha256: d3971dcdd76182a0c198c096b5db2f0884b0d4196723d21a866fc4cdea057ebc
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "12.1.0"
|
||||
permission_handler_apple:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: permission_handler_apple
|
||||
sha256: f000131e755c54cf4d84a5d8bd6e4149e262cc31c5a8b1d698de1ac85fa41023
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "9.4.7"
|
||||
permission_handler_html:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: permission_handler_html
|
||||
sha256: "38f000e83355abb3392140f6bc3030660cfaef189e1f87824facb76300b4ff24"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.1.3+5"
|
||||
permission_handler_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: permission_handler_platform_interface
|
||||
sha256: eb99b295153abce5d683cac8c02e22faab63e50679b937fa1bf67d58bb282878
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.3.0"
|
||||
permission_handler_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: permission_handler_windows
|
||||
sha256: "1a790728016f79a41216d88672dbc5df30e686e811ad4e698bfc51f76ad91f1e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.1"
|
||||
petitparser:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
name: twp_softphone
|
||||
description: TWP Softphone - WebView client for Twilio WordPress Plugin
|
||||
publish_to: 'none'
|
||||
version: 2.0.0+6
|
||||
version: 2.0.1+7
|
||||
|
||||
environment:
|
||||
sdk: ^3.5.0
|
||||
@@ -15,6 +15,7 @@ dependencies:
|
||||
flutter_local_notifications: ^17.0.0
|
||||
webview_flutter: ^4.10.0
|
||||
webview_flutter_android: ^4.3.0
|
||||
permission_handler: ^11.3.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
Reference in New Issue
Block a user