If the app uses Google FCM (which uses Google Play Services to poll notifications on device) it should register an FCM service that runs separately from the application, so it shouldn't need to run in the background.
However to answer your original question, you can disable battery optimization for particular apps. Or if an app wants to really never be killed, it can create an Android foreground service.
Rules for thee but not for me