You can only set a local notification either by some seconds in the future or some absolute time. There is no “set one tomorrow” type feature. You could either calculate the number of seconds (os.time() + (24 * 60 * 60) to get the same time tomorrow or some other method of setting your future date.
Here’s some code I use in my game Veggie Blast to help with retention. Hope it helps!
--schedule a retention message once a day over the next 30 days local minutesInSeconds = 60 local hoursInSeconds =minutesInSeconds\*60 local dayInSeconds = hoursInSeconds\*24 local currentTime = os.date() local currentHour = tonumber(currentTime:sub(12,13)) local currentMinutes = tonumber(currentTime:sub(15,16)) local currentSeconds = tonumber(currentTime:sub(18,19)) local secondsToRemoveToStartAt12am = (currentHour \* hoursInSeconds) - (currentMinutes \* minutesInSeconds) - currentSeconds local days = 30 local timeToSendNotification = 10\*hoursInSeconds --this will set it to go off at 10am every day for i=1, days do local time = dayInSeconds\*i - secondsToRemoveToStartAt12am + timeToSendNotification local options = { alert = "notification message", badge = 1, sound = "alert.caf", } system.scheduleNotification(time, options ) end
You can only set a local notification either by some seconds in the future or some absolute time. There is no “set one tomorrow” type feature. You could either calculate the number of seconds (os.time() + (24 * 60 * 60) to get the same time tomorrow or some other method of setting your future date.
Here’s some code I use in my game Veggie Blast to help with retention. Hope it helps!
--schedule a retention message once a day over the next 30 days local minutesInSeconds = 60 local hoursInSeconds =minutesInSeconds\*60 local dayInSeconds = hoursInSeconds\*24 local currentTime = os.date() local currentHour = tonumber(currentTime:sub(12,13)) local currentMinutes = tonumber(currentTime:sub(15,16)) local currentSeconds = tonumber(currentTime:sub(18,19)) local secondsToRemoveToStartAt12am = (currentHour \* hoursInSeconds) - (currentMinutes \* minutesInSeconds) - currentSeconds local days = 30 local timeToSendNotification = 10\*hoursInSeconds --this will set it to go off at 10am every day for i=1, days do local time = dayInSeconds\*i - secondsToRemoveToStartAt12am + timeToSendNotification local options = { alert = "notification message", badge = 1, sound = "alert.caf", } system.scheduleNotification(time, options ) end
Hi did you set a flag to tell your app that you have already setup notifications? I was wondering what would happen if I set up two notifications at the same time and they pile up?
Hi did you set a flag to tell your app that you have already setup notifications? I was wondering what would happen if I set up two notifications at the same time and they pile up?