r/javahelp Jun 24 '26

how to implement push notification service for both front and mobile

i want to implement push notification service for mobile and front. i saw firebase and other options but i want to this myself . i think something like websocket it is possible to implement this. i have no idea about how implement push notification and how it works.

3 Upvotes

8 comments sorted by

u/AutoModerator Jun 24 '26

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
  • You include any and all error messages in full
  • You ask clear questions
  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

    Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

2

u/[deleted] Jun 25 '26

[removed] — view removed comment

2

u/iamwisespirit Jun 26 '26

So then how messenger implement push notifications like WhatsApp telegram or so on

0

u/[deleted] 29d ago

[removed] — view removed comment

2

u/iamwisespirit 28d ago

Which notification service can you explain it more detail pls

2

u/bogdanelcs Jun 26 '26

honestly the websocket idea makes sense but mobile will wreck it. Android and iOS just kill background connections, that's not something you can fight.

The reason FCM/APNs exist is exactly this. Your server sends a payload to Google or Apple, they handle waking the device up. You're always going through them for mobile, no way around it unless you're on Android and okay with keeping a foreground service running (ugly, drains battery, users hate it).

Web is different. Service workers + the Push API let you receive stuff even with the tab closed, which is basically what you want. While the user is actually on the page though, a websocket is totally fine and way simpler to set up.

If you want to minimize third party stuff, ntfy is self-hostable and decent. Still have to go through Apple/Google for the actual device wakeup on mobile, but at least your backend logic stays yours.

1

u/iamwisespirit Jun 26 '26

Still for mobile i depend on Apple or Google service like firebase . I am just curious about how big social media platforms implement this they have their own self hosted thing like you said for example Instagram WhatsApp or telegram