I wrote a little application that gets started as a daemon. It basically will just output the phones GPS location.
the main.m:
int main(int argc, char *argv[]) {
NSAutoreleasePool *p = [[NSAutoreleasePool alloc] init];
LocationController *obj = [[LocationController alloc] init];
[obj getLocation];
NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
[runLoop run];
[p drain];
return 0;
}
the LocationController.m
@implementation LocationController
@synthesize locationManager;
-(id)init {
self = [super init];
if(self) {
trackingGPS = false;
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
}
return self;
}
-(void)getLocation {
[locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
NSLog(@"NEW LOCATION :: %@", newLocation);
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
NSLog(@"LOCATION ERROR : %@", error);
}
-(void) dealloc {
[locationManager release];
[super dealloc];
}
@end
So if I run the application manually off springboard, it works fine and logs the GPS location...at least for 15-20seconds...then springboard terminates the application because it doesn't repsond - an expected behavior.
If I however start the application at startup (launchDaemon), it also starts fine but the delegate function 'didUpdateToLocation' never get's called!!
I'm on iOS 5 so not sure what the problem is. Any help is truly appreciated.
THX !!