2026-03-07 17:11:02 -08:00
|
|
|
import 'dart:typed_data';
|
Add TWP Softphone Flutter app and complete mobile backend API
Backend: Add /voice/token endpoint with AccessToken + VoiceGrant for
mobile VoIP, implement unhold_call() with call leg detection, wire FCM
push notifications into call queue and webhook missed call handlers,
add data-only FCM message support for Android background wake, and add
Twilio API Key / Push Credential settings fields.
Flutter app: Full softphone with Twilio Voice SDK integration, JWT auth
with auto-refresh, SSE real-time queue updates, FCM push notifications,
Material 3 UI with dashboard, active call screen, dialpad, and call
controls (mute/speaker/hold/transfer).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:01:23 -08:00
|
|
|
import 'package:firebase_core/firebase_core.dart';
|
|
|
|
|
import 'package:firebase_messaging/firebase_messaging.dart';
|
2026-03-07 17:11:02 -08:00
|
|
|
import 'package:flutter/foundation.dart';
|
Add TWP Softphone Flutter app and complete mobile backend API
Backend: Add /voice/token endpoint with AccessToken + VoiceGrant for
mobile VoIP, implement unhold_call() with call leg detection, wire FCM
push notifications into call queue and webhook missed call handlers,
add data-only FCM message support for Android background wake, and add
Twilio API Key / Push Credential settings fields.
Flutter app: Full softphone with Twilio Voice SDK integration, JWT auth
with auto-refresh, SSE real-time queue updates, FCM push notifications,
Material 3 UI with dashboard, active call screen, dialpad, and call
controls (mute/speaker/hold/transfer).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:01:23 -08:00
|
|
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
|
|
|
|
|
2026-03-07 17:11:02 -08:00
|
|
|
/// Notification ID for queue alerts (fixed so we can cancel it).
|
|
|
|
|
const int _queueAlertNotificationId = 9001;
|
|
|
|
|
|
Replace native Twilio Voice SDK with WebView-based softphone
Rewrites the mobile app from a native Twilio Voice SDK integration
(Android Telecom/ConnectionService) to a thin WebView shell that loads
a standalone browser phone page from WordPress. This eliminates the
buggy Android phone account registration, fixes frequent logouts by
using 7-day WP session cookies instead of JWT tokens, and maintains
all existing call features (dialpad, queues, hold, transfer, requeue,
recording, caller ID, agent status).
Server-side:
- Add class-twp-mobile-phone-page.php: standalone /twp-phone/ endpoint
with mobile-optimized UI, dark mode, tab navigation, and Flutter
WebView JS bridge
- Extend auth cookie to 7 days for phone agents
- Add WP AJAX handler for FCM token registration (cookie auth)
Flutter app (v2.0.0):
- Replace 18 native files with 5-file WebView shell
- Login via wp-login.php in WebView (auto-detect redirect on success)
- Full-screen WebView with auto microphone grant for WebRTC
- FCM push notifications preserved for queue alerts
- Remove: twilio_voice, dio, provider, JWT auth, SSE, native call UI
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 09:11:25 -07:00
|
|
|
/// Background handler -- must be top-level function.
|
Add TWP Softphone Flutter app and complete mobile backend API
Backend: Add /voice/token endpoint with AccessToken + VoiceGrant for
mobile VoIP, implement unhold_call() with call leg detection, wire FCM
push notifications into call queue and webhook missed call handlers,
add data-only FCM message support for Android background wake, and add
Twilio API Key / Push Credential settings fields.
Flutter app: Full softphone with Twilio Voice SDK integration, JWT auth
with auto-refresh, SSE real-time queue updates, FCM push notifications,
Material 3 UI with dashboard, active call screen, dialpad, and call
controls (mute/speaker/hold/transfer).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:01:23 -08:00
|
|
|
@pragma('vm:entry-point')
|
|
|
|
|
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
|
|
|
|
|
await Firebase.initializeApp();
|
2026-03-07 17:11:02 -08:00
|
|
|
final data = message.data;
|
|
|
|
|
final type = data['type'];
|
|
|
|
|
|
|
|
|
|
if (type == 'queue_alert') {
|
|
|
|
|
await _showQueueAlertNotification(data);
|
|
|
|
|
} else if (type == 'queue_alert_cancel') {
|
|
|
|
|
final plugin = FlutterLocalNotificationsPlugin();
|
|
|
|
|
await plugin.cancel(_queueAlertNotificationId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Show an insistent queue alert notification (works from background handler too).
|
|
|
|
|
Future<void> _showQueueAlertNotification(Map<String, dynamic> data) async {
|
|
|
|
|
final plugin = FlutterLocalNotificationsPlugin();
|
|
|
|
|
|
|
|
|
|
final title = data['title'] ?? 'Call Waiting';
|
|
|
|
|
final body = data['body'] ?? 'New call in queue';
|
|
|
|
|
|
|
|
|
|
final androidDetails = AndroidNotificationDetails(
|
|
|
|
|
'twp_queue_alerts',
|
|
|
|
|
'Queue Alerts',
|
|
|
|
|
channelDescription: 'Alerts when calls are waiting in queue',
|
|
|
|
|
importance: Importance.max,
|
|
|
|
|
priority: Priority.max,
|
|
|
|
|
playSound: true,
|
|
|
|
|
sound: const RawResourceAndroidNotificationSound('queue_alert'),
|
|
|
|
|
enableVibration: true,
|
|
|
|
|
vibrationPattern: Int64List.fromList([0, 500, 200, 500, 200, 500]),
|
|
|
|
|
ongoing: true,
|
|
|
|
|
autoCancel: false,
|
|
|
|
|
category: AndroidNotificationCategory.alarm,
|
|
|
|
|
additionalFlags: Int32List.fromList([4]), // FLAG_INSISTENT = 4
|
|
|
|
|
fullScreenIntent: true,
|
|
|
|
|
visibility: NotificationVisibility.public,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await plugin.show(
|
|
|
|
|
_queueAlertNotificationId,
|
|
|
|
|
title,
|
|
|
|
|
body,
|
|
|
|
|
NotificationDetails(android: androidDetails),
|
|
|
|
|
);
|
Add TWP Softphone Flutter app and complete mobile backend API
Backend: Add /voice/token endpoint with AccessToken + VoiceGrant for
mobile VoIP, implement unhold_call() with call leg detection, wire FCM
push notifications into call queue and webhook missed call handlers,
add data-only FCM message support for Android background wake, and add
Twilio API Key / Push Credential settings fields.
Flutter app: Full softphone with Twilio Voice SDK integration, JWT auth
with auto-refresh, SSE real-time queue updates, FCM push notifications,
Material 3 UI with dashboard, active call screen, dialpad, and call
controls (mute/speaker/hold/transfer).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:01:23 -08:00
|
|
|
}
|
|
|
|
|
|
Replace native Twilio Voice SDK with WebView-based softphone
Rewrites the mobile app from a native Twilio Voice SDK integration
(Android Telecom/ConnectionService) to a thin WebView shell that loads
a standalone browser phone page from WordPress. This eliminates the
buggy Android phone account registration, fixes frequent logouts by
using 7-day WP session cookies instead of JWT tokens, and maintains
all existing call features (dialpad, queues, hold, transfer, requeue,
recording, caller ID, agent status).
Server-side:
- Add class-twp-mobile-phone-page.php: standalone /twp-phone/ endpoint
with mobile-optimized UI, dark mode, tab navigation, and Flutter
WebView JS bridge
- Extend auth cookie to 7 days for phone agents
- Add WP AJAX handler for FCM token registration (cookie auth)
Flutter app (v2.0.0):
- Replace 18 native files with 5-file WebView shell
- Login via wp-login.php in WebView (auto-detect redirect on success)
- Full-screen WebView with auto microphone grant for WebRTC
- FCM push notifications preserved for queue alerts
- Remove: twilio_voice, dio, provider, JWT auth, SSE, native call UI
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 09:11:25 -07:00
|
|
|
/// Push notification service for queue alerts and general notifications.
|
|
|
|
|
///
|
|
|
|
|
/// FCM token registration is handled via the WebView JavaScript bridge
|
|
|
|
|
/// instead of a REST API call. The token is exposed via [fcmToken] and
|
|
|
|
|
/// injected into the web page by [PhoneScreen].
|
Add TWP Softphone Flutter app and complete mobile backend API
Backend: Add /voice/token endpoint with AccessToken + VoiceGrant for
mobile VoIP, implement unhold_call() with call leg detection, wire FCM
push notifications into call queue and webhook missed call handlers,
add data-only FCM message support for Android background wake, and add
Twilio API Key / Push Credential settings fields.
Flutter app: Full softphone with Twilio Voice SDK integration, JWT auth
with auto-refresh, SSE real-time queue updates, FCM push notifications,
Material 3 UI with dashboard, active call screen, dialpad, and call
controls (mute/speaker/hold/transfer).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:01:23 -08:00
|
|
|
class PushNotificationService {
|
|
|
|
|
final FirebaseMessaging _messaging = FirebaseMessaging.instance;
|
|
|
|
|
final FlutterLocalNotificationsPlugin _localNotifications =
|
|
|
|
|
FlutterLocalNotificationsPlugin();
|
2026-03-07 17:11:02 -08:00
|
|
|
String? _fcmToken;
|
|
|
|
|
|
|
|
|
|
String? get fcmToken => _fcmToken;
|
Add TWP Softphone Flutter app and complete mobile backend API
Backend: Add /voice/token endpoint with AccessToken + VoiceGrant for
mobile VoIP, implement unhold_call() with call leg detection, wire FCM
push notifications into call queue and webhook missed call handlers,
add data-only FCM message support for Android background wake, and add
Twilio API Key / Push Credential settings fields.
Flutter app: Full softphone with Twilio Voice SDK integration, JWT auth
with auto-refresh, SSE real-time queue updates, FCM push notifications,
Material 3 UI with dashboard, active call screen, dialpad, and call
controls (mute/speaker/hold/transfer).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:01:23 -08:00
|
|
|
|
|
|
|
|
Future<void> initialize() async {
|
|
|
|
|
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
|
|
|
|
|
|
|
|
|
|
await _messaging.requestPermission(
|
|
|
|
|
alert: true,
|
|
|
|
|
badge: true,
|
|
|
|
|
sound: true,
|
|
|
|
|
criticalAlert: true,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Initialize local notifications
|
|
|
|
|
const androidSettings =
|
|
|
|
|
AndroidInitializationSettings('@mipmap/ic_launcher');
|
|
|
|
|
const initSettings = InitializationSettings(android: androidSettings);
|
|
|
|
|
await _localNotifications.initialize(initSettings);
|
|
|
|
|
|
Replace native Twilio Voice SDK with WebView-based softphone
Rewrites the mobile app from a native Twilio Voice SDK integration
(Android Telecom/ConnectionService) to a thin WebView shell that loads
a standalone browser phone page from WordPress. This eliminates the
buggy Android phone account registration, fixes frequent logouts by
using 7-day WP session cookies instead of JWT tokens, and maintains
all existing call features (dialpad, queues, hold, transfer, requeue,
recording, caller ID, agent status).
Server-side:
- Add class-twp-mobile-phone-page.php: standalone /twp-phone/ endpoint
with mobile-optimized UI, dark mode, tab navigation, and Flutter
WebView JS bridge
- Extend auth cookie to 7 days for phone agents
- Add WP AJAX handler for FCM token registration (cookie auth)
Flutter app (v2.0.0):
- Replace 18 native files with 5-file WebView shell
- Login via wp-login.php in WebView (auto-detect redirect on success)
- Full-screen WebView with auto microphone grant for WebRTC
- FCM push notifications preserved for queue alerts
- Remove: twilio_voice, dio, provider, JWT auth, SSE, native call UI
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 09:11:25 -07:00
|
|
|
// Get FCM token
|
Add TWP Softphone Flutter app and complete mobile backend API
Backend: Add /voice/token endpoint with AccessToken + VoiceGrant for
mobile VoIP, implement unhold_call() with call leg detection, wire FCM
push notifications into call queue and webhook missed call handlers,
add data-only FCM message support for Android background wake, and add
Twilio API Key / Push Credential settings fields.
Flutter app: Full softphone with Twilio Voice SDK integration, JWT auth
with auto-refresh, SSE real-time queue updates, FCM push notifications,
Material 3 UI with dashboard, active call screen, dialpad, and call
controls (mute/speaker/hold/transfer).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:01:23 -08:00
|
|
|
final token = await _messaging.getToken();
|
Replace native Twilio Voice SDK with WebView-based softphone
Rewrites the mobile app from a native Twilio Voice SDK integration
(Android Telecom/ConnectionService) to a thin WebView shell that loads
a standalone browser phone page from WordPress. This eliminates the
buggy Android phone account registration, fixes frequent logouts by
using 7-day WP session cookies instead of JWT tokens, and maintains
all existing call features (dialpad, queues, hold, transfer, requeue,
recording, caller ID, agent status).
Server-side:
- Add class-twp-mobile-phone-page.php: standalone /twp-phone/ endpoint
with mobile-optimized UI, dark mode, tab navigation, and Flutter
WebView JS bridge
- Extend auth cookie to 7 days for phone agents
- Add WP AJAX handler for FCM token registration (cookie auth)
Flutter app (v2.0.0):
- Replace 18 native files with 5-file WebView shell
- Login via wp-login.php in WebView (auto-detect redirect on success)
- Full-screen WebView with auto microphone grant for WebRTC
- FCM push notifications preserved for queue alerts
- Remove: twilio_voice, dio, provider, JWT auth, SSE, native call UI
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 09:11:25 -07:00
|
|
|
debugPrint(
|
|
|
|
|
'FCM token: ${token != null ? "${token.substring(0, 20)}..." : "NULL"}');
|
Add TWP Softphone Flutter app and complete mobile backend API
Backend: Add /voice/token endpoint with AccessToken + VoiceGrant for
mobile VoIP, implement unhold_call() with call leg detection, wire FCM
push notifications into call queue and webhook missed call handlers,
add data-only FCM message support for Android background wake, and add
Twilio API Key / Push Credential settings fields.
Flutter app: Full softphone with Twilio Voice SDK integration, JWT auth
with auto-refresh, SSE real-time queue updates, FCM push notifications,
Material 3 UI with dashboard, active call screen, dialpad, and call
controls (mute/speaker/hold/transfer).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:01:23 -08:00
|
|
|
if (token != null) {
|
2026-03-07 17:11:02 -08:00
|
|
|
_fcmToken = token;
|
|
|
|
|
} else {
|
Replace native Twilio Voice SDK with WebView-based softphone
Rewrites the mobile app from a native Twilio Voice SDK integration
(Android Telecom/ConnectionService) to a thin WebView shell that loads
a standalone browser phone page from WordPress. This eliminates the
buggy Android phone account registration, fixes frequent logouts by
using 7-day WP session cookies instead of JWT tokens, and maintains
all existing call features (dialpad, queues, hold, transfer, requeue,
recording, caller ID, agent status).
Server-side:
- Add class-twp-mobile-phone-page.php: standalone /twp-phone/ endpoint
with mobile-optimized UI, dark mode, tab navigation, and Flutter
WebView JS bridge
- Extend auth cookie to 7 days for phone agents
- Add WP AJAX handler for FCM token registration (cookie auth)
Flutter app (v2.0.0):
- Replace 18 native files with 5-file WebView shell
- Login via wp-login.php in WebView (auto-detect redirect on success)
- Full-screen WebView with auto microphone grant for WebRTC
- FCM push notifications preserved for queue alerts
- Remove: twilio_voice, dio, provider, JWT auth, SSE, native call UI
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 09:11:25 -07:00
|
|
|
debugPrint(
|
|
|
|
|
'FCM: Failed to get token - Firebase may not be configured correctly');
|
Add TWP Softphone Flutter app and complete mobile backend API
Backend: Add /voice/token endpoint with AccessToken + VoiceGrant for
mobile VoIP, implement unhold_call() with call leg detection, wire FCM
push notifications into call queue and webhook missed call handlers,
add data-only FCM message support for Android background wake, and add
Twilio API Key / Push Credential settings fields.
Flutter app: Full softphone with Twilio Voice SDK integration, JWT auth
with auto-refresh, SSE real-time queue updates, FCM push notifications,
Material 3 UI with dashboard, active call screen, dialpad, and call
controls (mute/speaker/hold/transfer).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:01:23 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Listen for token refresh
|
Replace native Twilio Voice SDK with WebView-based softphone
Rewrites the mobile app from a native Twilio Voice SDK integration
(Android Telecom/ConnectionService) to a thin WebView shell that loads
a standalone browser phone page from WordPress. This eliminates the
buggy Android phone account registration, fixes frequent logouts by
using 7-day WP session cookies instead of JWT tokens, and maintains
all existing call features (dialpad, queues, hold, transfer, requeue,
recording, caller ID, agent status).
Server-side:
- Add class-twp-mobile-phone-page.php: standalone /twp-phone/ endpoint
with mobile-optimized UI, dark mode, tab navigation, and Flutter
WebView JS bridge
- Extend auth cookie to 7 days for phone agents
- Add WP AJAX handler for FCM token registration (cookie auth)
Flutter app (v2.0.0):
- Replace 18 native files with 5-file WebView shell
- Login via wp-login.php in WebView (auto-detect redirect on success)
- Full-screen WebView with auto microphone grant for WebRTC
- FCM push notifications preserved for queue alerts
- Remove: twilio_voice, dio, provider, JWT auth, SSE, native call UI
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 09:11:25 -07:00
|
|
|
_messaging.onTokenRefresh.listen((token) {
|
|
|
|
|
_fcmToken = token;
|
|
|
|
|
});
|
Add TWP Softphone Flutter app and complete mobile backend API
Backend: Add /voice/token endpoint with AccessToken + VoiceGrant for
mobile VoIP, implement unhold_call() with call leg detection, wire FCM
push notifications into call queue and webhook missed call handlers,
add data-only FCM message support for Android background wake, and add
Twilio API Key / Push Credential settings fields.
Flutter app: Full softphone with Twilio Voice SDK integration, JWT auth
with auto-refresh, SSE real-time queue updates, FCM push notifications,
Material 3 UI with dashboard, active call screen, dialpad, and call
controls (mute/speaker/hold/transfer).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:01:23 -08:00
|
|
|
|
Replace native Twilio Voice SDK with WebView-based softphone
Rewrites the mobile app from a native Twilio Voice SDK integration
(Android Telecom/ConnectionService) to a thin WebView shell that loads
a standalone browser phone page from WordPress. This eliminates the
buggy Android phone account registration, fixes frequent logouts by
using 7-day WP session cookies instead of JWT tokens, and maintains
all existing call features (dialpad, queues, hold, transfer, requeue,
recording, caller ID, agent status).
Server-side:
- Add class-twp-mobile-phone-page.php: standalone /twp-phone/ endpoint
with mobile-optimized UI, dark mode, tab navigation, and Flutter
WebView JS bridge
- Extend auth cookie to 7 days for phone agents
- Add WP AJAX handler for FCM token registration (cookie auth)
Flutter app (v2.0.0):
- Replace 18 native files with 5-file WebView shell
- Login via wp-login.php in WebView (auto-detect redirect on success)
- Full-screen WebView with auto microphone grant for WebRTC
- FCM push notifications preserved for queue alerts
- Remove: twilio_voice, dio, provider, JWT auth, SSE, native call UI
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 09:11:25 -07:00
|
|
|
// Handle foreground messages
|
Add TWP Softphone Flutter app and complete mobile backend API
Backend: Add /voice/token endpoint with AccessToken + VoiceGrant for
mobile VoIP, implement unhold_call() with call leg detection, wire FCM
push notifications into call queue and webhook missed call handlers,
add data-only FCM message support for Android background wake, and add
Twilio API Key / Push Credential settings fields.
Flutter app: Full softphone with Twilio Voice SDK integration, JWT auth
with auto-refresh, SSE real-time queue updates, FCM push notifications,
Material 3 UI with dashboard, active call screen, dialpad, and call
controls (mute/speaker/hold/transfer).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:01:23 -08:00
|
|
|
FirebaseMessaging.onMessage.listen(_handleForegroundMessage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _handleForegroundMessage(RemoteMessage message) {
|
|
|
|
|
final data = message.data;
|
|
|
|
|
final type = data['type'];
|
|
|
|
|
|
Replace native Twilio Voice SDK with WebView-based softphone
Rewrites the mobile app from a native Twilio Voice SDK integration
(Android Telecom/ConnectionService) to a thin WebView shell that loads
a standalone browser phone page from WordPress. This eliminates the
buggy Android phone account registration, fixes frequent logouts by
using 7-day WP session cookies instead of JWT tokens, and maintains
all existing call features (dialpad, queues, hold, transfer, requeue,
recording, caller ID, agent status).
Server-side:
- Add class-twp-mobile-phone-page.php: standalone /twp-phone/ endpoint
with mobile-optimized UI, dark mode, tab navigation, and Flutter
WebView JS bridge
- Extend auth cookie to 7 days for phone agents
- Add WP AJAX handler for FCM token registration (cookie auth)
Flutter app (v2.0.0):
- Replace 18 native files with 5-file WebView shell
- Login via wp-login.php in WebView (auto-detect redirect on success)
- Full-screen WebView with auto microphone grant for WebRTC
- FCM push notifications preserved for queue alerts
- Remove: twilio_voice, dio, provider, JWT auth, SSE, native call UI
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 09:11:25 -07:00
|
|
|
// Queue alert -- show insistent notification
|
2026-03-07 17:11:02 -08:00
|
|
|
if (type == 'queue_alert') {
|
|
|
|
|
_showQueueAlertNotification(data);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
Replace native Twilio Voice SDK with WebView-based softphone
Rewrites the mobile app from a native Twilio Voice SDK integration
(Android Telecom/ConnectionService) to a thin WebView shell that loads
a standalone browser phone page from WordPress. This eliminates the
buggy Android phone account registration, fixes frequent logouts by
using 7-day WP session cookies instead of JWT tokens, and maintains
all existing call features (dialpad, queues, hold, transfer, requeue,
recording, caller ID, agent status).
Server-side:
- Add class-twp-mobile-phone-page.php: standalone /twp-phone/ endpoint
with mobile-optimized UI, dark mode, tab navigation, and Flutter
WebView JS bridge
- Extend auth cookie to 7 days for phone agents
- Add WP AJAX handler for FCM token registration (cookie auth)
Flutter app (v2.0.0):
- Replace 18 native files with 5-file WebView shell
- Login via wp-login.php in WebView (auto-detect redirect on success)
- Full-screen WebView with auto microphone grant for WebRTC
- FCM push notifications preserved for queue alerts
- Remove: twilio_voice, dio, provider, JWT auth, SSE, native call UI
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 09:11:25 -07:00
|
|
|
// Queue alert cancel -- dismiss notification
|
2026-03-07 17:11:02 -08:00
|
|
|
if (type == 'queue_alert_cancel') {
|
|
|
|
|
_localNotifications.cancel(_queueAlertNotificationId);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Show local notification for other types (missed call, etc.)
|
Add TWP Softphone Flutter app and complete mobile backend API
Backend: Add /voice/token endpoint with AccessToken + VoiceGrant for
mobile VoIP, implement unhold_call() with call leg detection, wire FCM
push notifications into call queue and webhook missed call handlers,
add data-only FCM message support for Android background wake, and add
Twilio API Key / Push Credential settings fields.
Flutter app: Full softphone with Twilio Voice SDK integration, JWT auth
with auto-refresh, SSE real-time queue updates, FCM push notifications,
Material 3 UI with dashboard, active call screen, dialpad, and call
controls (mute/speaker/hold/transfer).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:01:23 -08:00
|
|
|
_localNotifications.show(
|
|
|
|
|
message.hashCode,
|
|
|
|
|
data['title'] ?? 'TWP Softphone',
|
|
|
|
|
data['body'] ?? '',
|
|
|
|
|
const NotificationDetails(
|
|
|
|
|
android: AndroidNotificationDetails(
|
|
|
|
|
'twp_general',
|
|
|
|
|
'General Notifications',
|
|
|
|
|
importance: Importance.high,
|
|
|
|
|
priority: Priority.high,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-03-07 17:11:02 -08:00
|
|
|
|
Replace native Twilio Voice SDK with WebView-based softphone
Rewrites the mobile app from a native Twilio Voice SDK integration
(Android Telecom/ConnectionService) to a thin WebView shell that loads
a standalone browser phone page from WordPress. This eliminates the
buggy Android phone account registration, fixes frequent logouts by
using 7-day WP session cookies instead of JWT tokens, and maintains
all existing call features (dialpad, queues, hold, transfer, requeue,
recording, caller ID, agent status).
Server-side:
- Add class-twp-mobile-phone-page.php: standalone /twp-phone/ endpoint
with mobile-optimized UI, dark mode, tab navigation, and Flutter
WebView JS bridge
- Extend auth cookie to 7 days for phone agents
- Add WP AJAX handler for FCM token registration (cookie auth)
Flutter app (v2.0.0):
- Replace 18 native files with 5-file WebView shell
- Login via wp-login.php in WebView (auto-detect redirect on success)
- Full-screen WebView with auto microphone grant for WebRTC
- FCM push notifications preserved for queue alerts
- Remove: twilio_voice, dio, provider, JWT auth, SSE, native call UI
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 09:11:25 -07:00
|
|
|
/// Cancel any active queue alert.
|
2026-03-07 17:11:02 -08:00
|
|
|
void cancelQueueAlert() {
|
|
|
|
|
_localNotifications.cancel(_queueAlertNotificationId);
|
|
|
|
|
}
|
Add TWP Softphone Flutter app and complete mobile backend API
Backend: Add /voice/token endpoint with AccessToken + VoiceGrant for
mobile VoIP, implement unhold_call() with call leg detection, wire FCM
push notifications into call queue and webhook missed call handlers,
add data-only FCM message support for Android background wake, and add
Twilio API Key / Push Credential settings fields.
Flutter app: Full softphone with Twilio Voice SDK integration, JWT auth
with auto-refresh, SSE real-time queue updates, FCM push notifications,
Material 3 UI with dashboard, active call screen, dialpad, and call
controls (mute/speaker/hold/transfer).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:01:23 -08:00
|
|
|
}
|