diff --git a/lib/main.dart b/lib/main.dart index 066017b..dec5a7e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -169,6 +169,10 @@ class _H5ShellPageState extends State with WidgetsBindingObserver { }, ) ..setJavaScriptMode(JavaScriptMode.unrestricted) + ..addJavaScriptChannel( + 'OpenIMFlutterShell', + onMessageReceived: _handleShellBridgeMessage, + ) ..setBackgroundColor(_shellBackground) ..setNavigationDelegate( NavigationDelegate( @@ -234,6 +238,22 @@ class _H5ShellPageState extends State with WidgetsBindingObserver { return controller; } + void _handleShellBridgeMessage(JavaScriptMessage message) { + String? type; + try { + final decoded = jsonDecode(message.message); + if (decoded is Map) { + type = decoded['type'] as String?; + } + } catch (_) { + type = message.message; + } + + if (type == 'openAppSettings') { + unawaited(openAppSettings()); + } + } + void _showTransientShellCover() { _shellCoverTimer?.cancel(); if (mounted) {