Sensor Values notifications help

Hey guys , I searched a lot and I couldn't find a solution to my problem.
I have sensor that sends true if electricity is available to a redis data base , and false if there is not electricity available. In my mit app , I read these data , if electricity is cut for 10 minutes the app sends me a notification to the lock screen " Electricty is cut for 10 minutes"
Everything is done , but still the notification.
I need the app to send me that notification , even it's not working in the foreground and even the backgroud.
For example "whatapp or telegram or many other apps , can still send notifications even if the user didn't open the application on android start up" , or for example the Alarm of my phone , can show notification even if the app is not working at all
I need the simplest solution please

We already talked about your task in detail in orher threads, for example here

What about continuing there?
It really does not make sense to start from the beginning again and again...