Can I schedule events/callbacks at specified times each day in PhoneGap

末鹿安然 提交于 2020-01-14 08:14:10

问题


Is there any way (in PhoneGap) I can schedule events or callbacks to happen at designated times each day?

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.


回答1:


You could use this:

https://github.com/katzer/cordova-plugin-local-notifications.git

It allows you to use local notifications of the device.

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.

I have used this with Moment JS to handle my timed notifications.



来源:https://stackoverflow.com/questions/21115844/can-i-schedule-events-callbacks-at-specified-times-each-day-in-phonegap

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!