Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Local Notifications
Started by kakula Sep 01 2018 03:26 PM

3 replies to this topic
local notifications certain time
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

kakula

[GLOBAL: userInfoPane.html]
kakula
  • Enthusiast

  • 70 posts
  • Corona SDK

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



[TOPIC: post.html]
#2

kakula

[GLOBAL: userInfoPane.html]
kakula
  • Enthusiast

  • 70 posts
  • Corona SDK

anyone there!?



[TOPIC: post.html]
#3

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,535 posts
  • Corona Staff

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



[TOPIC: post.html]
#4

kakula

[GLOBAL: userInfoPane.html]
kakula
  • Enthusiast

  • 70 posts
  • Corona SDK

Thanks man

 

i will give it a try




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: local, notifications, certain time