Add FCM push notifications, queue alerts, caller ID fixes, and auto-revert agent status
All checks were successful
Create Release / build (push) Successful in 6s
All checks were successful
Create Release / build (push) Successful in 6s
Server-side: - Add push credential auto-creation for FCM incoming call notifications - Add queue alert FCM notifications (data-only for background delivery) - Add queue alert cancellation on call accept/disconnect - Fix caller ID to show caller's number instead of Twilio number - Fix FCM token storage when refresh_token is null - Add pre_call_status tracking to revert agent status 30s after call ends - Add SSE fallback polling for mobile app connectivity Mobile app: - Add Android telecom permissions and phone account registration - Add VoiceFirebaseMessagingService for incoming call push handling - Add insistent queue alert notifications with custom sound - Fix caller number display on active call screen - Add caller ID selection dropdown on dashboard - Add phone numbers endpoint and provider support - Add unit tests for CallInfo, QueueState, and CallProvider - Remove local.properties from tracking, add .gitignore Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -26,14 +26,32 @@ class TWP_Mobile_SSE {
|
||||
'callback' => array($this, 'stream_events'),
|
||||
'permission_callback' => array($this->auth, 'verify_token')
|
||||
));
|
||||
register_rest_route('twilio-mobile/v1', '/stream/poll', array(
|
||||
'methods' => 'GET',
|
||||
'callback' => array($this, 'poll_state'),
|
||||
'permission_callback' => array($this->auth, 'verify_token')
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Return current state as JSON (polling alternative to SSE)
|
||||
*/
|
||||
public function poll_state($request) {
|
||||
$user_id = $this->auth->get_current_user_id();
|
||||
if (!$user_id) {
|
||||
return new WP_Error('unauthorized', 'Invalid token', array('status' => 401));
|
||||
}
|
||||
return rest_ensure_response($this->get_current_state($user_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Stream events to mobile app
|
||||
*/
|
||||
public function stream_events($request) {
|
||||
error_log('TWP SSE: stream_events called');
|
||||
$user_id = $this->auth->get_current_user_id();
|
||||
error_log('TWP SSE: user_id=' . ($user_id ?: 'false'));
|
||||
|
||||
if (!$user_id) {
|
||||
return new WP_Error('unauthorized', 'Invalid token', array('status' => 401));
|
||||
@@ -56,6 +74,15 @@ class TWP_Mobile_SSE {
|
||||
ob_end_flush();
|
||||
}
|
||||
|
||||
// Flush padding to overcome Apache/HTTP2 frame buffering.
|
||||
// SSE comments (lines starting with ':') are ignored by clients.
|
||||
// We send >4KB to ensure the first HTTP/2 DATA frame is flushed.
|
||||
echo ':' . str_repeat(' ', 4096) . "\n\n";
|
||||
if (ob_get_level() > 0) ob_flush();
|
||||
flush();
|
||||
|
||||
error_log('TWP SSE: padding flushed, sending connected event');
|
||||
|
||||
// Send initial connection event
|
||||
$this->send_event('connected', array('user_id' => $user_id, 'timestamp' => time()));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user