I'm currently developing a website that relies on firebase messaging
. To make this happen, a specialized service worker for firebase
has been integrated into the site.
This website functions as a webchat platform where messages are synchronized and stored in the firebase database
. The site utilizes angular-ui-router
to retrieve message keys from the URL. Whenever a new message is received from a client, a notification is displayed. Clicking on this notification modifies the URL to display the related message. However, there's been an issue with the service worker when the website isn't in focus, resulting in an error message stating "unable to navigate
".
The code snippet for the service worker looks like this:
(service worker code here)
The desired behavior for the website is outlined below:
When in focus:
- Receive message
- Show notification
- Modify URL upon notification click
URL before notification click: https://example.com/#!/
URL after notification click: https://example.com/#!/-key
When not in focus:
- Receive push notification
- Adjust data for notification display
- Show notification
- Focus/open website upon notification click
- Modify URL upon focus/open
URL when focused/opened: https://example.com/#!/-key
The notification display code works fine when the website is in focus, so I don't believe it's necessary to include that code here.
Any assistance on this matter would be greatly appreciated, as I've exhausted all possible solutions I could think of.