Search code examples
messagecommunicationsend

How do i get messages even if the app is closed


It is more or less asking how Whattsapp, Instagram, Facebook etc works. How does my Phone know i got a new message even if the app is closed

(Please dont focus that much on the examples above, it is more a general question.)

I can think of a couple of solutions:

1.My Phone asks (in the background) an api every couple of seconds and fetches the data.

2.My Phone has an on going connection over the Web(i heard of technologies like: WebSocket, WebRTC, WebTransport, (standard) sockets, TCP)

  1. My Phone is running a Webserver 24/7 and gets the signal like that

So in general the question is how can my PC/Phone etc. wait for a signal/data (Im talking 1, 2 or 3 bytes) in the background efficiently


Solution

  • it Highly Depends on the Operating System that the Program is Running on and also each OS has its own specific Security & Privacy Policy. However, all of them have a Common Agreement that this Types of Operation should be Handled in Background Processes as Secure Lightweight as Possible. so for your listed solution the closest one is 1th case.

    2th Case almost Impossible because it is in Contradiction to being Lightweight
    3th Case totally wrong way