allowsBackgroundLocationUpdates in CLLocationManager in iOS9

This new property is explained in the WWDC session “What’s New in Core Location”. The default value is NO if you link against iOS 9. If your app uses location in the background (without showing the blue status bar) you have to set allowsBackgroundLocationUpdates to YES in addition to setting the background mode capability in … Read more

Start Location Manager in iOS 7 from background task

I found the problem/solution. When it is time to start location service and stop background task, background task should be stopped with a delay (I used 1 second). Otherwise location service wont start. Also Location Service should be left ON for a couple of seconds (in my example it is 3 seconds). Another important notice, … Read more

How to retrieve user’s current city name?

As of iOS 5 MKReverseGeoCoder is Deprecated! So you want to use CLGeocoder with CLLocationManager, very simple and works with block. Example: – (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { [self.locationManager stopUpdatingLocation]; CLGeocoder * geoCoder = [[CLGeocoder alloc] init]; [geoCoder reverseGeocodeLocation:newLocation completionHandler:^(NSArray *placemarks, NSError *error) { for (CLPlacemark *placemark in placemarks) { …. = [placemark … Read more

Background Location Services not working in iOS 7

Here is the solution that I used to get continuous location from iOS 7 devices no matter it is in foreground or background. You may find the full solution and explanation from blog and also github:- Background Location Update Programming for iOS 7 and 8 Github Project: Background Location Update Programming for iOS 7 and … Read more

Periodic iOS background location updates

It seems that stopUpdatingLocation is what triggers the background watchdog timer, so I replaced it in didUpdateLocation with: [self.locationManager setDesiredAccuracy:kCLLocationAccuracyThreeKilometers]; [self.locationManager setDistanceFilter:99999]; which appears to effectively power down the GPS. The selector for the background NSTimer then becomes: – (void) changeAccuracy { [self.locationManager setDesiredAccuracy:kCLLocationAccuracyBest]; [self.locationManager setDistanceFilter:kCLDistanceFilterNone]; } All I’m doing is periodically toggling the accuracy … Read more

How do I get a background location update every n minutes in my iOS application?

I found a solution to implement this with the help of the Apple Developer Forums: Specify location background mode Create an NSTimer in the background with UIApplication:beginBackgroundTaskWithExpirationHandler: When n is smaller than UIApplication:backgroundTimeRemaining it will work just fine. When n is larger, the location manager should be enabled (and disabled) again before there is no … Read more

tech