What I'm trying to ask is:
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.
Open your phone's Settings app > Apps > WhatsApp > Data usage. Make sure background data is not restricted. Repeat the above steps for Google Services.
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.
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.
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).
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With