Background services in ionic

I’d like to build an app which does an audio alert and a vibration when the sun rises for a given location.
I already have the formula to compute the sunrise times.

Since the sunrise time is a function of the current date. the time would constantly be changing for each and every day. So we got a moving target here. As a result, I cannot just set it as 5:00AM like the alarm-clock-apps would do. The app must run in the background and know what time the beep will be for the next sunrise.

If the app is kept alive on the front, then, implementing this would not be an issue much. I already got that part done.

But, I’m just not sure how to deal with this goal WHEN the screen is off?

I’m also curious as to how alarm-clock-apps deal with recovering from a complete power off and yet still remember to fire those alarms even after phone boots off. ( I assume achieving that would be even more complicated. ).

I hope you already resolved this, but there’s a plugin that may help you: https://github.com/uniclau/AlarmPlugin

Did you find any solution for this ??