Vaishnavi Shende
Vaishnavi Shende

Reputation: 1

How to Maintain CometD Connection Across Page Navigations for Desktop Notifications in a Web Application?

I’m working on a web application where I need to show desktop notifications for real-time updates (e.g., Case updates in Salesforce) using CometD. The notifications should start working during a specific popup (e.g., a login flow popup) and should continue to work even after the user navigates away from the popup, without embedding the solution on any persistent Salesforce page.

Current Implementation: I’ve built a web page that uses CometD to subscribe to a topic (e.g., /topic/Caseupadte).

The page is displayed in a popup during a login flow.

When the user clicks "Continue," they are redirected to another page, and the popup closes.

Problem: The CometD connection works fine while the popup is open, but as soon as the user navigates away (e.g., clicks "Continue"), the connection is lost, and notifications stop.

I’ve tried enabling WebSocket transport and configuring automatic reconnection, but the connection is still lost when the page is unloaded.

What I’ve Tried: WebSocket Configuration:

Enabled WebSocket transport and fallback to long polling.

Added reconnect, maxConnections, and backoffIncrement for automatic reconnection.

Expectation: The notifications should start working during a specific popup page(e.g., a login flow popup) and should continue to work even after the user navigates away from the popup page, without embedding the solution on any persistent Salesforce page.

Upvotes: 0

Views: 24

Answers (0)

Related Questions