Need an example of scheduled alarm/notification using Corona

So I tried to make a scheduled alarm/notification with customizable hour and minute field.

What I did basically is :

first create the alarm :

 idAlarm = notifications.scheduleNotification( SecondsToAdd, optionsAlarm ) myData.settings.alarmID = idAlarm utility.saveTable(myData.settings, "settings.json") --save  
  1. default time is 07:00 (24-hours)

  2. user can change hour (e.g. from 07 into 14)

  3. save the time into settings -> 14:00

  4. remove initial alarm using id, create a new one at 14.00

    notifications.cancelNotification( idAlarm)

The problem is, the previous alarm was not removed, so I have double alarm/notification.

the next problem is how to make it run daily?

note: for now I just want to make a scheduled notification, not alarm. But if you can provide an example for both I will be happy :D…

Thank you :slight_smile:

This is a limitation of our notifications. The value returned by notifications.scheduleNotification is a type called “userdata”. This is a block of allocated C memory that Lua returns from the C based API that’s creating the notification. “userdata” types do not persist between runs of the app and can’t be saved and reused. There is no good way to cancel the notification after the app has exited.

Rob

This is a limitation of our notifications. The value returned by notifications.scheduleNotification is a type called “userdata”. This is a block of allocated C memory that Lua returns from the C based API that’s creating the notification. “userdata” types do not persist between runs of the app and can’t be saved and reused. There is no good way to cancel the notification after the app has exited.

Rob