Search code examples
cordovacordova-pluginsvisual-studio-cordova

Add Task Scheduler


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!


Solution

  • 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!