Phase 3.1: Local notification for WS chat requests, router fix, cleanup

- Show local notification (sound + vibrate) when chat_request arrives
  via WebSocket while mitra app is backgrounded
- Add NotificationService.showLocalNotification() for programmatic use
- Fix router redirect: don't redirect auth routes to splash during loading
- Handle binary/string WebSocket frames in ChatRequestNotifier
- Remove debug logging from backend and Flutter
- Control center: mitra ping config UI
- Both apps: dynamic ping, FCM deep-linking, unread badges

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-09 14:57:36 +08:00
parent 1b249e34b0
commit 2e80434e9b
2 changed files with 45 additions and 4 deletions

View File

@@ -83,6 +83,36 @@ class NotificationService {
_navigateFromMessage(message.data);
}
/// Show a local notification programmatically (e.g. from WebSocket while backgrounded)
static Future<void> showLocalNotification({
required String title,
required String body,
Map<String, dynamic>? data,
}) async {
await _localNotifications.show(
id: DateTime.now().millisecondsSinceEpoch % 100000,
title: title,
body: body,
notificationDetails: NotificationDetails(
android: AndroidNotificationDetails(
_channel.id,
_channel.name,
channelDescription: _channel.description,
importance: Importance.high,
priority: Priority.high,
playSound: true,
enableVibration: true,
),
iOS: const DarwinNotificationDetails(
presentAlert: true,
presentBadge: true,
presentSound: true,
),
),
payload: data != null ? jsonEncode(data) : null,
);
}
static void _navigateFromMessage(Map<String, dynamic> data) {
if (_router == null) return;
final sessionId = data['session_id'] as String?;