Run APP like WhatsApp

Firebase is what you are looking for.
For chats use Real-time Database
Push notification works in the background also (Even after closing the the app completely)

By the way, you may have a wrong impression that whatsapp is active all the time. Whatsapp app is not active. Only services like push notification is active in the background.