Prateek Surana
Prateek Surana

Reputation: 692

how to set local notification in cordova every day at a particular time

I want to give local notification at 7:00 am every day using cordova local notification plugin but in the documentation it is not specified how to set time for a repeating notification

       $cordovaLocalNotification.schedule({
             id: 3,
             title: 'Warning',
             text: 'Dont fall asleep',
             every: 'minute'
           }).then(function (result) {
             console.log('Notification 3 triggered');
         });

Upvotes: 1

Views: 1711

Answers (2)

Javier Sirgo
Javier Sirgo

Reputation: 159

If you are using cordova-plugin-local-notifications, I think It should be:

var date = new Date()
date.setDate(date.getDate()+1);
date.setHours(7);
date.setMinutes(0);
date.setSeconds(0);
$cordovaLocalNotification.schedule({
    id: 3,
    title: 'Warning',
    text: 'Dont fall asleep',
    at: date,
    every: 'day'
}).then(function (result) {
    console.log('Notification 3 triggered');
});

This should schedule a notification the next day at 7, that will be repeated every day, but I couldn't try it, I'm sorry.

Upvotes: 2

Sathyajith
Sathyajith

Reputation: 4024

The property for setting the time is firstAt. You can find out the documentation about the plugin here.

Upvotes: 0

Related Questions