how to send background notification to client on chat web app

Viewed 17

i am creating a web based chatting application with firebase and next.js. which is currently in development.

the problem i am facing is i want to have push notification for every new message received to user when the app in not in foreground. is their any thing to do with service worker?

i thought of using service worker to do so. but i don't know how to write service worker. i have stored user auth token in react context can i use it in service worker ?

i am fetching chats from messages array stored in firestore doc of chat between two people.

0 Answers
Related