tags:

views:

42

answers:

3

I want to make a special calendar app, but I am afraid it's not possible to safely schedule an alert for an event.

For example: I set up an alert for an event which starts in 3 months. I want to get notified 2 days before the event starts. In iOS 4 there is multitasking, so my app could run in the background all the time.

But now lets imagine it's a hardcore iPhone user who plays huge memory-intensive games all the time. At some point, iOS might kill my background app. Or the user might restart the device and forget to launch my app. So it could happen that the alert never happens. Bad thing.

Is there a safe way to ensure that an scheduled alert is thrown at the user, just like it is the case with the built in alarm clock app or the calendar app?

+1  A: 

You want to use UILocalNotification for this.

EventKit will make it pop up in the user's calendar, maybe not what you want here.

BTW: Multitasking is really more "fast switching" than backgrounding in iOS... you won't be able to run arbitrary code in background, and you should expect to be killed anytime.

Eiko
Unfortunately there is an odd limit of 64 scheduled notifications per app. That's bad...
openfrog
Well... not really. Just schedule the next notifications when your app runs. I cannot image that someone "ignores" 64 messages but is angry about not being informed for the 65th. This should only happen if you use the notifications as the only user interface, which really is an extreme case.
Eiko
+1  A: 

here is a pretty detail tutorial on doing what you have requested

http://icodeblog.com/2010/07/29/iphone-programming-tutorial-local-notifications/

Aaron Saunders
+1  A: 

I'm going to bring back the EventKit notification - use event kit to schedule a calendar entry with an alert, and embed in there a URL that will open your app.

You could also use local notifications but this way the user will be able to see the upcoming event when reviewing the calendar, and even modify slightly if need be. They can't mess with a local notification once it's in place...

Kendall Helmstetter Gelner
but the app can change or delete/recreate the local notification if the user wants to change it, right?
openfrog
I think you can, but I've not used the API yet. But it would mean that you'd also have to provide a management UI for the user, where if you just throw it in the normal calendar you can tell them to change it there.
Kendall Helmstetter Gelner