I have noticed something related to this.
In my daily phone I use
Messages from Google as my SMS app. Using that app means I also can have
https://messages.google.com/ open in a browser window on my desktop computer. The phone and that window are connected so I can both read and write my SMS messages from the comfort of my computer. When a message arrive and the desktop windows sees it, it throws up a notification on my monitor. Pretty much like how the Android phone shows a notification when a SMS message arrives.
So far so good. The strange thing I've noticed many times is that the computer shows the message BEFORE the phone. Let's go through the steps to be sure what happens:
1. Somebody sends me a SMS message
2. Phone receive it
3. Phone send it to Google to show on the webpage
4. Webpage receive message and show notification
5. Time passes (0-10 minutes)
6. Phone display notification
So perhaps Android is simply very unwilling to light up the screen to show a notification (that in many cases are not even seen by the user). You know, as a battery-saving thing. It would mean that the message actually arrive as it should, it's just that the phone doesn't inform the user.
If this is correct, then I suppose we should use code to wake the phone briefly when we get a message so it reasons "oh, screen is lit, I might as well show this waiting notification"
Note that I have no actual evidence of anything here, other than the fact that the phone often shows the notifications after the computer. The rest is just my best guess.