Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

cordova

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.

like image 390
Matt Whetton Avatar asked Jan 14 '14 14:01

Matt Whetton


1 Answers

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.

like image 111
Ian Jamieson Avatar answered Sep 22 '22 14:09

Ian Jamieson