简体   繁体   English

如何在apache cordova上安排活动?

[英]How to schedule an events on apache cordova?

I m developing a simple Alarm Application html using cordova and phonegap. 我正在使用cordova和phonegap开发一个简单的Alarm Application html It works like this. 它的工作原理如下。

  1. User Selects the alarm time 用户选择闹钟时间

  2. App Stores the time on database. App将时间存储在数据库中。

  3. Alarm plays a sound on selected time. 闹钟在选定的时间播放声音。

Now all the 1 and 2 steps are done. 现在所有的1步和2步都完成了。 But for step 3 how app can know when to play the sound? 但对于第3步,应用程序如何知道何时播放声音? Is there something like cron job in html or cordova? 在html或cordova中有类似cron job吗? 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. 我知道javascript setInterval函数但是有限制。 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). setInterval仅在您的应用程序正在运行(和前台)时才有效。 A better solution is to use the local notifications plugin and set a sound to be played. 更好的解决方案是使用本地通知插件并设置要播放的声音。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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