My Application starts a service to periodically poll a database and create a local notification under certain conditions (e.g. a production line going down). This all works fine at first but when the device goes to sleep then no notifications are received. From googling it seems this might be to do with Doze mode where Android 6 onwards disables network access for background apps. I have marked my App as "NOT OPTIMISED" in Settings > Battery > Battery Optimisation but the notifications still don't get raised. The background service isn't listed here so I had to select the main App.
Please could you tell me how I can get my service to work even when the device goes to sleep. It must be possible as apps like WhatsApp still receive messages and notify the user when the device is asleep.