Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempted to send a second callback for ID: AlarmPlugin411429347 #3

Open
segolas-zoso opened this issue Jul 19, 2015 · 1 comment
Open

Comments

@segolas-zoso
Copy link

Hi,

I can't get this to work.

Here is my code:

setAlarm = function(){
    var alarmDate = new Date().getTime();
    console.log("current time: "+alarmDate);
    alarmDate = alarmDate + 2000;
    console.log("in two seconds: "+alarmDate);
    console.log("setting the local notification at "+alarmDate);
    navigator.plugins.alarm.set(alarmDate, 
        function(){
            // SUCCESS
            console.log("alarm triggered at "+alarmDate);
        }, 
        function(){
          // ERROR
          console.log("Error triggering the alarm "+alarmDate);
        })
};

On the android logcat I've got the error in the subject or, if I grep for "Web Console" I have the "Error triggering the alarm" message.

any idea what's wrong with my code? Looks pretty straightforward to me

@jbaylina
Copy link
Contributor

alarmDate should be a javascript Date object.

You can fix the code this way.

var alarmDate = new Date().getTime();
alarmDate = alarmDate + 2000; // milliseconds
navigator.plugins.alarm.set(new Date(alarmDate), 
        function(){
            // SUCCESS
            console.log("alarm triggered at "+alarmDate);
        }, 
        function(){
          // ERROR
          console.log("Error triggering the alarm "+alarmDate);
        });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants