You don’t need to have the app running in the background. Notifications can be pushed from the cloud.
Problem is, that costs money to host and run that job to check for notifications. This is why a lot of small developers end up burying notifications behind a paywall.
Speaking for iOS, I don’t believe this is possible. iOS has rules around what background processes can and can’t run on-device.
For notifications coming from the internet, in order to preserve battery life, Apple wants cloud APNs to wake up terminated apps to deliver notifications.
I know android does some similar battery preservation stuff around notifications, but I’m a little less familiar with that.