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:
@@ -279,22 +279,68 @@ class TWP_FCM {
|
||||
}
|
||||
|
||||
/**
|
||||
* Send incoming call notification
|
||||
* Send queue alert notification (call entered queue).
|
||||
* Uses data-only message so it works in background/killed state.
|
||||
*/
|
||||
public function notify_incoming_call($user_id, $from_number, $queue_name, $call_sid) {
|
||||
$title = 'Incoming Call';
|
||||
$body = "Call from $from_number in $queue_name queue";
|
||||
public function notify_queue_alert($user_id, $from_number, $queue_name, $call_sid) {
|
||||
$title = 'Call Waiting';
|
||||
$body = "Call from $from_number in $queue_name";
|
||||
|
||||
$data = array(
|
||||
'type' => 'incoming_call',
|
||||
'type' => 'queue_alert',
|
||||
'call_sid' => $call_sid,
|
||||
'from_number' => $from_number,
|
||||
'queue_name' => $queue_name
|
||||
'queue_name' => $queue_name,
|
||||
);
|
||||
|
||||
return $this->send_notification($user_id, $title, $body, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel queue alert notification (call answered or caller disconnected).
|
||||
*/
|
||||
public function notify_queue_alert_cancel($user_id, $call_sid) {
|
||||
$data = array(
|
||||
'type' => 'queue_alert_cancel',
|
||||
'call_sid' => $call_sid,
|
||||
);
|
||||
|
||||
return $this->send_notification($user_id, '', '', $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send queue alert cancel to all agents assigned to a queue.
|
||||
*/
|
||||
public function cancel_queue_alert_for_queue($queue_id, $call_sid) {
|
||||
global $wpdb;
|
||||
$queue_table = $wpdb->prefix . 'twp_call_queues';
|
||||
|
||||
$queue = $wpdb->get_row($wpdb->prepare(
|
||||
"SELECT * FROM $queue_table WHERE id = %d", $queue_id
|
||||
));
|
||||
if (!$queue) return;
|
||||
|
||||
$notified_users = array();
|
||||
|
||||
// Notify personal queue owner
|
||||
if (!empty($queue->user_id)) {
|
||||
$this->notify_queue_alert_cancel($queue->user_id, $call_sid);
|
||||
$notified_users[] = $queue->user_id;
|
||||
}
|
||||
|
||||
// Notify agent group members
|
||||
if (!empty($queue->agent_group_id)) {
|
||||
require_once dirname(__FILE__) . '/class-twp-agent-groups.php';
|
||||
$members = TWP_Agent_Groups::get_group_members($queue->agent_group_id);
|
||||
foreach ($members as $member) {
|
||||
if (!in_array($member->user_id, $notified_users)) {
|
||||
$this->notify_queue_alert_cancel($member->user_id, $call_sid);
|
||||
$notified_users[] = $member->user_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send queue timeout notification
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user