I want to implement a notification to the post author as soon as there is a comment on the post. In other words, when a request to write a comment comes to the server, the server wants to send a notification to the author in real time. Of course, I also want to give the commenter a push notification when the author of the post has commented on a comment.
The server is implemented with Spring Boot, and I am considering websockets to send push notifications from server to client. However, before I try, I have a few concerns and ask a question.
As I understand it, websockets is a web protocol that enables two-way communication between a server and a client over a single TCP connection. In other words, in order to implement a push notification that a comment has been made to a mobile app, I think that a TCP connection must be maintained at all times. I am wondering if it is possible to send push notifications using websockets from server to client even when the client app is in background state or is off. My guess is that if the TCP connection goes down, The app won't get push notifications.
I think WebSocket is suitable for full-duplex two-way communication such as chatting, but wouldn't it be expensive to implement a websocket that occasionally sends push notifications from the server to the client?
The function I want to create is a function that notifies only the author of a specific post with a comment when a comment is posted. Is it appropriate for websocket to implement a function that notifies only a specific user?
I just know that websocket is one of the methods for sending data from server to client, and I tried to use websocket for push notification, but I don't know if it's the right way to go.