简体   繁体   中英

How to schedule an events on apache cordova?

I m developing a simple Alarm Application html using cordova and phonegap. It works like this.

  1. User Selects the alarm time

  2. App Stores the time on database.

  3. Alarm plays a sound on selected time.

Now all the 1 and 2 steps are done. But for step 3 how app can know when to play the sound? Is there something like cron job in html or cordova? I need something which can schedule time to execute a function everyday on selected time. I know the javascript setInterval function but there are limitation on this. It schedules time again when page is refreshed, and there will be also multiple alarms on my app. Please suggest me how to do this. Thanks in advance.

setInterval only works if your app is running (and foreground). A better solution is to use the local notifications plugin and set a sound to be played.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM