0
如何在我的应用程序中实现每日本地通知?因此,首先我需要在14:00登记第一次当地通知,然后每天14:00登记通知。如何在特定时间每天注册本地通知?
用户可以在应用程序的设置中更改此时间。
如何做到这一点?
如何在我的应用程序中实现每日本地通知?因此,首先我需要在14:00登记第一次当地通知,然后每天14:00登记通知。如何在特定时间每天注册本地通知?
用户可以在应用程序的设置中更改此时间。
如何做到这一点?
您需要处理您的最终的notifcations,而是使每个人一天countsdown一定时间的计时器,你需要做这样的事情:
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,reminderOptions)' – Romowski