Notifications 如何在特定时间每天注册本地通知?
如何在我的应用程序中实现每日本地通知?所以在第一次运行时,我需要在14:00注册第一个本地通知,然后每天14:00通知就会出现 用户可以在应用程序的设置中更改此时间Notifications 如何在特定时间每天注册本地通知?,notifications,coronasdk,Notifications,Coronasdk,如何在我的应用程序中实现每日本地通知?所以在第一次运行时,我需要在14:00注册第一个本地通知,然后每天14:00通知就会出现 用户可以在应用程序的设置中更改此时间 如何实现这一机制?您需要处理本端的通知,但要制作一个计时器,使其每天计数到某个特定时间,您需要执行以下操作: local targetDate = os.time{ year=2014, month=11, day=8, hour=0, sec=0 } -- Get the date that you want to count d
如何实现这一机制?您需要处理本端的通知,但要制作一个计时器,使其每天计数到某个特定时间,您需要执行以下操作:
local targetDate = os.time{ year=2014, month=11, day=8, hour=0, sec=0 } -- Get the date that you want to count down to, in seconds
local text = false
local function enterFrame(event)
if text then text:removeSelf() end -- Everyframe, remove the old text object
local timeRemaining = (targetDate-os.time()) -- Take the difference between the target time and the current time
local days = timeRemaining / 86400 -- get the number of days left by dividing the remaining seconds by the number of seconds in a day
local hours = days%1 * 24 -- get the number of hours left by multiplying the remainder by the number hours in a day
local minutes = hours%1 * 60 -- get the number of minutes by multiplying the remainder by the number of minutes in an hour
local seconds = math.floor( minutes%1 * 60 + 0.5) -- multiply the remainder one more time by the number of seconds in a minute, and round to the nearest second.
-- make a new text object to display all the info
text = display.newText( "Will be available in "..math.floor(days).." days "..math.floor(hours).." hrs "..math.floor(minutes).." mins "..seconds.." secs ", 25, 140)
end
Runtime:addEventListener( "enterFrame", enterFrame )
您可以重新调整代码的用途以处理您的项目,但您需要使用操作系统时间并对每个变量进行某些计算以获得时间。祝你好运。谢谢!在notificationListener中,我应该称之为:localNotif=system.scheduleNotification(86400,提醒选项)