benbahrenburg / benCoding.AlarmManager

Titanium Module for working with the Android AlarmManager
Other
98 stars 85 forks source link

Delay when Add new Alarm. #58

Closed A7medArafah closed 9 years ago

A7medArafah commented 9 years ago

I try to use AlarmManager Module and it work done , but it make delay in time min or 2 min . alarmManager.addAlarmNotification({ requestCode:requestCode, icon:Ti.App.Android.R.drawable.appicon , year: now.getFullYear(), month: now.getMonth(), day: now.getDate(), hour: now.getHours(), minute: now.getMinutes() + 2 , //Set the number of minutes until the alarm should go off playSound:true, sound:Ti.Filesystem.getResRawDirectory() + 'sound.wav' , contentTitle:'Alarm #3', //Set the title of the Notification that will appear contentText:'Alarm & Notify Scheduled', //Set the body of the notification that will apear repeat:'daily' //You can use the words hourly,daily,weekly,monthly,yearly or you can provide milliseconds. //Or as shown above you can provide the millesecond value }); i donnot know why this delay , any suggestion.

AppWerft commented 9 years ago

In my projects I'm using only the parameter 'seconds'. This are the time difference from now. If you are using using moment.js, it is very simple:

var seconds = Moment(data.time).unix() - Moment().unix();
michielvaneerd commented 9 years ago

Maybe this is because since Android API 19 the notifications are not exact anymore. You can see it for yourself in your code above: if you remove the repeat in your code, the notification will be exact and if you add it, it will not be exact. I created a pull request to remedy this.

A7medArafah commented 9 years ago

When i add second it work done , thanks for your comments . but i have other issue notification open app again , even if it still open .i need to open the app opened not open new .