Of course, an OEM may do aggressive app killing where the above may not work (Huawei is notorious for this), but that is an OEM-specific issue that applies to all apps in general, so as a developer it’s up to you whether you want to test against, or even support such OEMs.
There are alternatives. Pushy is pretty easy to use, and it’s not that hard to allow it to run in the background. See: https://support.pushy.me/hc/en-us/articles/360043423332-How-can-I-send-notifications-to-Android-devices-in-Doze-power-saving-mode-
Of course, an OEM may do aggressive app killing where the above may not work (Huawei is notorious for this), but that is an OEM-specific issue that applies to all apps in general, so as a developer it’s up to you whether you want to test against, or even support such OEMs.