Hacker News new | ask | show | jobs
by nukeop 2661 days ago
I'm not up to date with Android, but why does displaying notifications require an entire server or a paid service? Is it not just a matter of installing a client program and sending a curl to an endpoint?
5 comments

You need a way to tell the mobile device that a new message has been received. Since you don't have a fixed IP or anything there is no way to directly send the message.

An alternative is that the mobile device pulls from time to time, but that's quite power intensive or, when using a long interval, is slow.

Instead one has an idle connection open to which the server can send messages.

It is not needed for displaying the notification but specifically targeting users. You would usually call an FCM function to get a token, which can be used to specifically target that user and is stored in the database. To send a notification to your customised target audience based on user-generated events, it becomes essential to use web-service that does it for you.

For example- Let's say you wish to send a notification to user A when user B sends him a message. In this scenario, you can call another FCM fn, using the token user A had generated. Of course you can use the web dashboard to send the notifications, but in this case, you would not be able to send event-based notification reliability and in real-time. Other services also work in a similar manner.

Of course FCM also has notion of channels where you can broadcast to certain topics (which apps listen to) without having to track tokens on application server side.
> I'm not up to date with Android, but why does displaying notifications require an entire server or a paid service? Is it not just a matter of installing a client program and sending a curl to an endpoint?

Imagine if every program on the users phone had their own schedule for checking for updates against remote hosts. That sounds terribly inefficient and wasteful of power, as the applications would need to "wake up" (as in, consume processor cycles) to initiate and perform a check.

Google's solution - Firebase Cloud Messaging is for the most part free and fairly easy to setup. Yes you can use curl to call their HTTP/REST endpoint to send a notification I believe.

If you get to the stage of sending millions of notifications per day then you'll need to start paying,

Sending a curl to an endpoint from the client is not push but pull. The idea of push notifications is that they arrive immediately.