Most apps use a foreground service. Using that the app is treated like an app running in the foreground and not like an app running in the background.
https://developer.android.com/guide/components/foreground-se...
Foreground services require a persistent notification, which looks more like a nasty hack than a proper workaround.
As far as I know the app can just ask to run in the background and then it works. Problem is many apps don't use the native dialog box to request it, and instead ask the user to go to settings and do it manually.
It was a monumentally stupid "feature". Even Samsung's default email app on my Samsung flagship phone only detects new emails every 20 minutes or so, which suggests that top-tier OEMs also have trouble getting past the ruthless background app killer.
I'm glad that at least a couple of FOSS apps have found a way around this problem. I'm curious how FairEmail (and now K9, too) pulled it off. Is there an official "do not kill" flag now, or are they just using some sort of loophole that allows IMAP IDLE connections to be kept alive in the background?