Local Notifications

Hi

the example on Local notifications looks very easy

but i’m still unable to understand how to make it run let’s say everyday at 5 pm

this is the code in general but how to make it run at 5pm

local utcTime = os.date( "!\*t", os.time() + 60 ) local notification2 = notifications.scheduleNotification( utcTime, options )

Regards,

Tariq

anyone there!?

This code:

local utcTime = os.date( "!\*t", os.time() + 60 )

gets a future time that is one minute in the future. You need to look at the os.date() documentation:

http://docs.coronalabs.com/api/library/os/time.html

It returns a table that contains the components of the date/time (year, month, day, hour, min, sec). Change the t.hour to 17 to get it to be 5pm local time. Then you can convert the table back to unix seconds and then add 86,400 to it (number of seconds in a day) to get the 5pm time tomorrow and set the notification for it. But it will only set one notification for tomorrow. 

If you want more days, say 30 days worth, use a for loop and keep adding 86400 to the value to keep getting a new date further in the future.

Rob

Thanks man

i will give it a try

anyone there!?

This code:

local utcTime = os.date( "!\*t", os.time() + 60 )

gets a future time that is one minute in the future. You need to look at the os.date() documentation:

http://docs.coronalabs.com/api/library/os/time.html

It returns a table that contains the components of the date/time (year, month, day, hour, min, sec). Change the t.hour to 17 to get it to be 5pm local time. Then you can convert the table back to unix seconds and then add 86,400 to it (number of seconds in a day) to get the 5pm time tomorrow and set the notification for it. But it will only set one notification for tomorrow. 

If you want more days, say 30 days worth, use a for loop and keep adding 86400 to the value to keep getting a new date further in the future.

Rob

Thanks man

i will give it a try