Add Task Scheduler

。_饼干妹妹 提交于 2019-12-23 20:27:55

问题


I´m developing an Apache Cordova application and I want to know if I can add tasks to the scheduler device.

I have to run an alarm and notification at a specific time, how can I do this?

I thought about adding a task to the scheduler device and delegate responsibility.

This is possible? At least Android 4.4

Thanks!


回答1:


first off all: Yes, you're of course able to do so. Sebastian Katzer wrote a plugin for that. It can be found here: Cordova - Local Notification Plugin.

This Plugin allows you to trigger scheduled Events or for example: Trigger events every Monday at 6 a.m. The Code for a standard notification looks like this:

cordova.plugins.notification.local.schedule({
    id: 1,
    title: "Production Jour fixe",
    text: "Duration 1h",
    firstAt: monday_9_am,
    every: "week",
    sound: "file://sounds/reminder.mp3",
    icon: "http://icons.com/?cal_id=1",
    data: { meetingId:"123#fg8" }
});

cordova.plugins.notification.local.on("click", function (notification) {
    joinMeeting(notification.data.meetingId);
});

The message looks like a Notification - a picture of that can be found here: Picture - Katzer Local Notifications

There also is a wiki which can be found here: Local Notifications by Katzer Wiki

Hope i helped you! Let me know if you need further information!



来源:https://stackoverflow.com/questions/29747646/add-task-scheduler

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