我可以在PhoneGap中每天在指定的时间安排事件/回调 [英] Can I schedule events/callbacks at specified times each day in PhoneGap
问题描述
有没有办法(在PhoneGap中)我可以安排每天在指定时间发生的事件或回调?
Is there any way (in PhoneGap) I can schedule events or callbacks to happen at designated times each day?
我想我在找Android
I guess I'm looking for something like Android AlarmManager, so that I can trigger some notification each day at a certain time, that would then prompt the user to launch my app.
感谢您的任何帮助
Matt
推荐答案
您可以使用:
https://github.com/katzer/cordova-plugin-local-notifications .git
它允许您使用设备的本地通知。
It allows you to use local notifications of the device.
安装此插件可以访问 window.plugin.notification.local
变量。然后可以运行:
Once you have installed this plugin you gain access to the window.plugin.notification.local
variable. You can then run:
window.plugin.notification.local.add({
date: new Date(),
message: 'Your notification message'
});
这将设置在指定日期在用户设备上显示的通知。
This will set a notification to appear on the users device at the specified date.
我使用此功能与 Moment JS 来处理我的定时通知。
I have used this with Moment JS to handle my timed notifications.
这篇关于我可以在PhoneGap中每天在指定的时间安排事件/回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!