UILocalNotification repeat alert 2 minutes later - ios

I just want to but sure I'm understanding this correctly.
It looks like the only way to have an UILocalNotification repeat ONLY ONCE 2 minutes after the first one is to schedule 2 separate local notifications.
Is that right?
I have seen posts similar to these:
How do I create a UILocalNotification that notifies every two minutes
https://stackoverflow.com/a/4923276/454404
https://stackoverflow.com/a/4022779/454404
They all seem to suggest the "schedule 2 notifications" route.
The Apple docs clearly say that you use Calendar units for repeats. So I guess you could set one to repeat a certain number of seconds after but then you would have to cancel it.
It just seems like there must be a better way.
Thanks

Have not found a better way that this.

Related

Repeating Local Notifications at specific intervals

Is it possible to have a notification repeat at specific intervals? For example, Remind me to do something on Monday to Friday (from 9:00am to 6:00pm)?
You can schedule local notifications for the specific time, date, weekday, and also specify to be repeated or not.
Here is a comprehensive document provided by Apple that describes how to do it.
If I'm not mistaken, You mean to schedule notification for a continuous period of time, If so, It does not make sense and it's not possible.
But you can schedule multiple notifications for different times of a weekday based on your need.

Timer in waiting game like clash of clans in iOS, clock change user proof

I've read this tutorial and this question, but when i use NSDate() or CFAbsoluteTimeGetCurrent() it is easy to trigger by the user setting the clock forward.
If i use CACurrentMediaTime(), the countdown seems not accurate at long time (1 hour or more).
How can I check the passed time correctly?
I must check the time in a server? How?
Thanks
You can use a free service such as http://timezonedb.com/api to get the current time. You just need to register for a free API key. No need to add all the extra time of implementing your own server for a simple task like getting the time

Swift: Creating a repeating local notification between a set time each day

I am trying to create a repeating local notification that will notify the user every hour between a set time every week day (e.g. 9-5 monday-friday) but after searching cant find any documentation on how to implement this.
If you want only 5/7 it can be a problem.
When you schedule a local notification you can also set a calendar unit as -repeatInterval property. This is cool because there is an per-app limit (maybe 64) of maximum number of notification that you can schedule, thus creating one you can fire it each day at the same time.
If you need to create a different kind of repetition is easy to reach that limit, to avoid that you can recreate further notifications each time the user open the app, or if you implement interactive notifications, each time the user interact with one.
Or but I've never tried you can create a notification for each day of the week NSWeekCalendarUnit(except sat and sun) an set the repetition to weekday for each, in this way you will only spend 5 notifications, for infinite repetition.

Architectural issue: Design of recurring events

I need to have a logic in our app, which allows to define recurring events (e.g. every tuesday, oder every 1st day of a month) which lead then to a specific action in the app.
I thought UILocalNotification would be a good idea, but with this class I send a notification also to the user and I want to process the event only in the app (If the app is not online, then may be the next time the app is up)
Another idea was to set up a list with the event and check every time the app is up, whether an event is due - but this seems quite old fashioned - hope there is something better.
Thanks a lot for any suggestion
You definitely want to use UILocalNotification in your situation, it will completely fulfill the needs that you described.
Since you said, the event should only fire whenever the app is active (in foreground) you will have to add some custom logic to make this happen, but this is not a very difficult task and you have multiple options here.
What I would suggest is that you use the app lifecycle methods of your AppDelegate, to schedule and remove your notifications when it's appropriate.
The UIApplicationDelegate protocol contains two relevant methods for your case (actually a bit more, but these two will do the job for you...). First we have applicationWillEnterBackground:, that's where you should remove all currently scheduled notifications. In the method applicationDidBecomeActive: you can then reschedule the notifications, as this one is called every time your app is coming to the foreground again.
Let me know if you have further questions :)

Can I change the message in a repeating UILocalNotification?

I have a UILocalNotification that repeats every hour and I would like to change the message when it repeats so it is different, or rotates between 3 messages.
Does anyone know of a way to do this?
Also, it appears I cannot customize my repeating local notifications beyond once every minute, hour, day, etc. What I'd like is a notification every 15 minutes. I suspect that can't be done though... unless you know a way?
Many thanks for assistance you can offer.
If you wanna change the message you can acces to the scheduledLocalNotifications array in your app delegate and modify the message, but to do that you need the app to be running. I think it's better to simply schedule different notifications with the different messages you want to show.
About the repeating interval the simple answers is no, you can't create your own repeating intervals. This is one of the many limitations that UILocalNotificationhas. Many apps (included mine) had solve the problem creating a queue of notifications. I explain that topic here

Resources