Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Whatsapp, Facebook and Skype messaging works in the background?

What I'm trying to ask is:

  1. Whether these apps are relying on FCM/GCM (or any other type of) push notifications for syncing their data or are they using a socket connection in background through a service?
  2. If they are relying on push notifications then why they don't have any loss in receiving notifications (in background) while I miss 10-15% of notifications in busy hours.
  3. And if they are relying on a socket connection in background, then ain't this eat battery like a dinosaur?

What I have found is that if I force stop Messenger and Facebook I still receive messages but somewhat late than usual. Plus there is an option of 'Allow background activity' in Messenger, Facebook, Slack and Skype, which when I disable, I can't receive a notification at all. Interesting this is that WhatsApp don't have this kinda option in its app info and If I just force stop WhatsApp it simply stops showing me message notifications.

like image 350
Muhammad Muzammil Avatar asked Jun 22 '18 13:06

Muhammad Muzammil


People also ask

Why is WhatsApp not working in the background?

Open your phone's Settings app > Apps > WhatsApp > Data usage. Make sure background data is not restricted. Repeat the above steps for Google Services.

Should WhatsApp run in the background?

For a smooth notification delivery, you should allow WhatsApp to run properly in the background. For iPhone users, you can go to devise Settings > WhatsApp > and toggle on the Background App Refresh option. Android users can long tap on the WhatsApp app icon to open app info.

How does WhatsApp receive messages in background?

Basically that means that technically you never quit WhatsApp. So, the way you receive messages while you're "not running" WhatsApp is the exact same way you receive them when you're running it. The client, in this case WhatsApp, connects to the server. The client maintains that connection.

How does WhatsApp work in the background?

It is just that the Apps and their component(such as Service) are being restarted as when they receive Push notifications, so that user can interact with the app. So, as and when Push notification is received (means WhatsApp message), Android can restart the killed app's component(in this case WhatsApp).


2 Answers

Whether these apps are relying on FCM/GCM (or any other type of) push notifications for syncing their data or are they using a socket connection in background through a service?

They must be relying on FCM.

If they are relying on push notifications then why they don't have any loss in receiving notifications (in background) while I miss 10-15% of notifications in busy hours.

They must be using FCM high priority which are reliably delivered in doze mode.

And if they are relying on a socket connection in background, then ain't this eat battery like a dinosaur?

They might not be running CPU intensive work.

Mobile applications like Whatsapp must be requesting permission to exempt them from Doze/battery saving and App standby mode. you can refer to my answer here for more details.

like image 117
Sagar Avatar answered Oct 11 '22 14:10

Sagar


Adding on to Sagar answer.

1)Never show the notification from FCM notification payload unless required.

2)Once High priority FCM received you can do network operations for sometime and fetch data from server and then show up. If it fails whatsapp do puts ups with special msg. https://www.quora.com/Why-do-I-get-You-may-have-new-messages-notification-on-WhatsApp

3)use foreground service/ cpu lock tied with app icon momentarily till the data is fetched ,later close it.

PS:No whatsapp do not request for Battery Optimization. they probably reply on FCM high-priority message.

like image 29
NitZRobotKoder Avatar answered Oct 11 '22 14:10

NitZRobotKoder