Reminders app - repeat a certain reminder - iphone

I'm building a reminders app, and been really interested in how to set a reminder to repeat itself every day/every month/every hour.
Basically I want to set something to repeat, even when my app is not running. In my case a local notification fire.
Thanks!

You can set the repeat interval easily using NSCalendarUnits
notification.repeatInterval= NSDayCalendarUnit;
For more calendar units check constants on http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSCalendar_Class/Reference/NSCalendar.html#//apple_ref/doc/c_ref/NSCalendarUnit

You have to use Local Push Notifications, because when your App is running in background this is the only way Apple would allow you to do something:
Check this for further info: http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Introduction/Introduction.html#//apple_ref/doc/uid/TP40008194-CH1-SW1
And this is a good tutorial about it: http://www.icodeblog.com/2010/07/29/iphone-programming-tutorial-local-notifications/

Check out Apple's reference documents here on using UILocalNotifications. I believe that is what you're looking for.
You can utilize UILocalNotifications to show a local notification at a certain time or date, whenever you like.
David Linsin also has a good post on this here.
Good Luck!

Related

Is it possible to run a scheduled timer in a suspended app?

I've read several posts on creating a timer that runs in the background. Is it possible to create a scheduled timer that will continue to run once the app has been suspended/terminated?
Apple's own timer achieves this, but it's not clear how. I am guessing they send a local notification for the timer expiry, and maybe they undertake a date object comparison if the app is brought to the foreground while still in the countdown period. Is this a correct assumption? Any pointers would be helpful.
In short, what you're looking to do is not possible - since the amount of time your app is allowed to run in the background is limited to ~3 minutes. Look at this answer for more details.
You could achieve your goal through the use of a push notification, but that would require a server and won't guarantee it is received at the perfect time.
You might also want to look at this question
It also appears based on this answer that you cannot set a timer in the standard clock app either.
TLDR - You can't create a timer app.

iOS NSNotification - how to safely ignore when coming out of suspended

Sometimes, when the app I'm working on comes out of suspended mode, I need to make sure it does not respond to the notifications iOS has saved for it while the app was suspended. Where's the right place to perform this cancellation where I can be sure my response code won't run?
I'm hoping that putting removeObserver is applicationWillEnterForeground would do the trick, but I couldn't find anything about this in the NSNotification doc.
Edit:
Let me add the details of the scenario:
The app I'm working on checks for changes to calendar events for the range of the next 7 days. It refreshes it's data (requeries eventStore) at two times:
1. When an NSNotification comes from the iPhone calendar about changes.
2. The first time the app is able to on a new day, because the 7 day range has changed.
The design challenge I'm having is the case where both scenarios are true at the same time (the app returns from being suspended and it's a new day, and calendar events were modified while the app was suspended ). I only want to requery the event store one time in that case. My thought is to, in applicationWillEnterForeground, on the case that it's the first launch of the day, tell the app to ignore or drop any notifications.
I'm getting the impression my assumptions about how NSNotifications would work in this case might be off. Any guidance would be great!
Why not remove the observer from the notification centre in -applicationDidEnterBackground:?
Then you can start observing again in -applicationWillEnterForeground:.
What NSNotifications come in while you’re suspended? Are you running a background task?
I can’t really think of a case where not responding to an NSNotification would be a good idea. They are effectively messages like any other, just with a different routing mechanism.
UILocalNotification would be a different issue.

How to show custom alert at specific time?

I'm working on an alarm/reminder application and want to show a custom alarm view when specified time is reached.
From what I understand, there are various (real and hypothetic) ways of doing it:
UILocalNotification. It would be perfect, but alert customization features are insufficient, e.g. I can't show a custom alert view, I can't play a sound for more than 30sec etc.
Keep application in the background and use NSTimer or other means to schedule execution after some time. Most likely won't work as the app may be killed any time.
Start my app at specified time to receive the notification. As far as I know it's not allowed at all.
After spending several days searching for a solution, I would give up and stick with UILocalNotification, but I DO know an app that shows custom alert view at specific time AND is available in AppStore. The app is named "Alarmed" and from what it looks like (last app view shown on alarm time before an actual alert; alarm still triggers even after the device is restarted) they found a way to start their app at specific time and still pass Apple's review.
Any ideas how this can be done?
Thanks.
It's not possible to show notifications other than what UILocalNotification offers you, unless the app is running in the foreground. (I just tried to install "Alarmed" and it uses a regular UILocalNotification like you'd expect).

How to regularly check for RSS/email-like updates online with iOS4

Is it possible to have an App (running iOS4 on hardware supporting multi-tasking) which starts on iPhone startup and then regularly checks for online updates (every 15 minutes) and then refresh the badge, so the user can see how many unread items there are with-out having a push-server?
I was hoping this would be possible with iOS4 Programming Guide seems to suggest it is only possible to to this regarding Locations tracking, VoIP and playing background audio. There is also the possibility to do local-push notifications, but I don't see to find how to trigger a specific function that way.
Thanks in advance for any help!
edit:
Just having read a bit more, if the application is in the background/inactive state, and I son want to update the badge-number without displaying a message, is there an action triggered like didReceiveLocalNotification? There must be a way to schedule something on a regular basis (like email checking) without having to implement a full server-push-nitification system!
Is it possible to have an App ... which starts on iPhone startup and then regularly checks for online updates (every 15 minutes) and then refresh the badge
As you already figured out, the answer is no.

Remove the app badge at a given hour

My app uses badge to count the number of smoked cigarettes in the current day. I would like the app to remove the badge at the midnight, when a new day begins... Is it possible to do that?
I mean, doing that while the app is closed!
Thanks
Interesting question. I don't think there is an elegant way to handle this; even multi-tasking falls short of being able to wake the app to perform a task. The only thing you're allowed to do is schedule a Local Notification, but this is only allowed to increase the badge number - sending a badge number of "0" indicates "no change".
Sorry there isn't a better answer.
andrew
Couldn't you just check, on application startup, if it was already started that day, and if not, remove the badge?