Schedule a local notification event to be delivered in the future.
Please see the corresponding blog tutorial for a walk-through of this feature.
1 2 | system.scheduleNotification( secondsFromNow [, options] ) system.scheduleNotification( coordinatedUniversalTime [, options] ) |
-- Options for iOS local options = { alert = "Wake up!", badge = 2, sound = "alarm.caf", custom = { foo = "bar" } } -- schedule using seconds from now local notification = system.scheduleNotification( 60, options ) -- schedule using UTC (Coordinated Universal Time) local utcTime = os.date( "!*t", os.time() + 60 ) local notification = system.scheduleNotification( utcTime, options ) local listener = function( event ) print( event.name ) -- ==> "notification" print( event.custom.foo ) -- ==> "bar" end Runtime:addEventListener( "notification", listener )
secondsFromNow
Number of seconds from now when the notification should be delivered.
coordinatedUniversalTime
Table containing same properties as returned by os.date( "!*t" ). A common error is to pass "*t" instead of "!*t" which incorrectly gives you the time in your current time zone.
options
Table specifying details about the notification to be delivered. The following keys can be specified:
In addition, the following iOS-specific options can be provided and (if specified) will be properties in the notification event that is to be delivered:
I have problem with scheduling notifications using UTC time - it doesn't matter what date and time I use it sets notification to be scheduled in 0 seconds or somewhere in the past ( i can't check what actually happens). So all my notifications created using UTC time ( or local, or whatever ) are available as soon as I schedule them.
I am using current stable build.
Notifications set using seconds are working correctly - is there any limit for number of seconds set?
I'd like this for Android as well - pushing alerts both on a schedule and based on in-app events (use cases).
Thanks.
Just FYI, I had the instant-notification thing, too.
I couldn't get the examples to work either: until I removed the '!' from the os.date format string.
(The docs say to use "*t", which works; the example uses "!*t", which seems not to.)
I think the info regarding badges is wrong... The badge parameter doesn't increment the number it sets it.
Would be good to see some clarification/confirmation from the Ansca staff, please..!
Greg
@spritestack: I updated the documentation to be more clear, thanks.
I'm interested in this feature on Android platform. Please, could you tell me when it will be operative on android devices?
Thanks in advance