Whatsapp doesn't run on background on new Xiaomi I got a new phone yesterday, Xiaomi Mi A1, and installed Whatsapp on it. Now I only get notifications when the app is open and a few minutes after I turn off the display (or go do some other thing). On my Whatsapp Web it says that the phone isn't connected, and I have to manually reopen the app in order to get any recent messages.

I figured it's some sort of restriction the Android places on background processes, but how do I remove it? I'm pretty sure I haven't messed with any sophisticated settings up until now
I strongly suspect this is caused by the enhanced App battery saver, which restricts  application activities to a minimum or altogether close an application to save power.

In some miui based Xiaomi phones it can be adjusted here: Security → Battery Usage → App battery saver → (Choose application) → Background settings:



Alternatively on non miui Xiaomi devices it can adjusted under App settings → Battery usage:



You have to turn off this setting or adjust to make sure the target application (Whatsapp) isn't killed in background.