2 Answers
2

What you want to do is not practically possible. Unless you use a method to keep your app active in the foreground all of the time, the alarm time will pass and your app will not be activating to run any code. Push notifications from a server are allowed to play sounds, display messages or change your app's badge number, but they do not run code in your app. Background execution is limited to 10 minutes of runtime, after which the OS will kill your app.

so what's the best thing that is possible? ask the user to turn the gps manually at time x?
–
aherlambangMar 1 '11 at 2:56

@MacTeo's answer is essentially correct, but battery life is going to be quite bad, especially if you set the accuracy high enough that it turns on the GPS radio.
–
Steve MadsenMar 1 '11 at 16:53

I am just curious in that app on the video, is that app basically having the GPS on all the time
–
aherlambangMar 1 '11 at 17:30

On iPhone 4, you can set up regions that will trigger when you enter or leave them. He might have used that for favorites. On 3GS and later, you can also use significant location change triggers, but this is based on cell towers and is coarse-grained (around 2 km). You'll note his slider for accuracy states it's a trade-off between location accuracy and battery life. That likely maps to the CLLocation accuracy, which in turn dictates what hardware is used. He says it periodically checks, so in the meantime it likely stops monitoring, which will help with power consumption.
–
Steve MadsenMar 1 '11 at 19:50

By set up regions, you mean we can code a particular region (lattitude, longitude) and when the phone hits that region it checks in?
–
aherlambangMar 1 '11 at 20:16

You can try to save battery life using the CLLocationManager's methods desiredAccuracy, distanceFilter and even the startMonitoringForRegion:desiredAccuracy: if you need exactly the same behavior shown in the video. In some devices you can even use the startMonitoringSignificantLocationChanges to avoid GPS and use just cellular network cell.
–
MacTeoMar 2 '11 at 6:56