Reputation: 2171
OK, here's a tough one (for me anyway)... My app has a button that checks to see if a user is in close proximity to a business. The button works almost perfectly by doing the following when it is pressed:
Like I mentioned, this works almost perfectly. I can walk towards a business continuously clicking the button as I approach the building and when I get close enough, the alert will tell me that I am less than 100 feet away.
My problem is that the alert displays wrong information if I send the app to the background while I am walking. For example, I open the app from very far away, then I send the app to the background and approach the business, then when I am right next to the business, I bring the app to the foreground and click the button and it says I am more than 100 feet away. Anyone have any ideas on why this might be happening?
In my viewDidLoad Method:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(appReturnsActive) name:UIApplicationDidBecomeActiveNotification
object:nil];
In appReturnsActive Method:
- (void)appReturnsActive{
locationManagerProfile.delegate = self;
locationManagerProfile.desiredAccuracy = kCLLocationAccuracyBest;
[locationManagerProfile startUpdatingLocation];
[locationManager startUpdatingLocation];
}
Upvotes: 0
Views: 155
Reputation: 1369
To save battery, location updates are stopped when your app goes to background. You can add a value to info.plist to keep your app updated. But you should carefully consider battery usage.
Upvotes: 1