Skip to content
Advertisement

How to schedule a periodic background work to activate at fixed times?

I want to push a notification every 12 hours at fixed times (lets say for an example, 9am and 9pm, every day). This is my current doWork() code:

JavaScript

`

and this is the work creation code:

JavaScript

I saw some people doing it with calendar but I don’t understand how it works.

Advertisement

Answer

I have found a simple solution, using calendar:

JavaScript

and the initial delay is set like so:

JavaScript

and this seems to work well.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement