Region Monitoring Glitch on iOS 7 – Multiple Notifications at the same time

I have found a fix for this strange bug. We have tested for over 1 week and so far we haven’t see the same bug again. Here is the solution:- -(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region{ NSLog(@”didEnterRegion”); CLLocation * lastLocation = [manager location]; BOOL doesItContainMyPoint; if(lastLocation==nil) doesItContainMyPoint = NO; else{ CLLocationCoordinate2D theLocationCoordinate = lastLocation.coordinate; CLCircularRegion * theRegion … Read more

How to rotate a Direction Arrow to particular location

This works for me: to rotate a Direction Arrow to particular location -(void)viewDidLoad { [super viewDidLoad]; locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.desiredAccuracy = kCLLocationAccuracyBest; locationManager.distanceFilter = kCLDistanceFilterNone; } -(void) calculateUserAngle:(CLLocationCoordinate2D)current { double x = 0, y = 0 , deg = 0,delLon = 0; delLon = fixLon – current.longitude; y = sin(delLon) … Read more

Implement CLLocationManagerDelegate methods in Swift

You need to add the NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription key to your plist if you haven’t already, they are now mandatory, iOS8+ requires one of these two strings to be set to use locations. Which one you use depends on how you intend ask for the location. Use NSLocationAlwaysUsageDescription for apps that want to use the … Read more

Why the CLLocationManager delegate is not getting called in iPhone SDK 4.0?

I had a similar error, and is solved now. The issue is declaring locationManager variable locally. Declare it instead as a class variable and make sure it is retained either directly or via property retain (or strong if you use ARC). That solves the problem! The issue was de locationManager variable was released and never … Read more

How to find your current location with CoreLocation

You can find your location using CoreLocation like this: import CoreLocation: #import <CoreLocation/CoreLocation.h> Declare CLLocationManager: CLLocationManager *locationManager; Initialize the locationManager in viewDidLoad and create a function that can return the current location as an NSString: – (NSString *)deviceLocation { return [NSString stringWithFormat:@”latitude: %f longitude: %f”, locationManager.location.coordinate.latitude, locationManager.location.coordinate.longitude]; } – (void)viewDidLoad { locationManager = [[CLLocationManager alloc] … Read more

Get location name from Latitude & Longitude in iOS

I’m giving you snippet which I’m using for resolving address. I’m including comment also at neccessary place to understand the code for you. Besides that feel free to ask any question from snippet if you get fail to understand anything. Write following snippet in didUpdateToLocation method NSLog(@”didUpdateToLocation: %@”, newLocation); CLLocation *currentLocation = newLocation; if (currentLocation … Read more

iOS Geofence CLCircularRegion monitoring. locationManager:didExitRegion does not seem to work as expected

I don’t think region monitoring will work well for such a small radius. The best accuracy with the GPS chip and kCLLocationAccuracyBestForNavigation is often just 10 meters. Apple says (in the Location & Maps PG) that the minimum distance for regions should be assumed to be 200m I’ve heard that region monitoring is using WiFi … Read more

Behaviour for significant change location API when terminated/suspended?

Since I asked this question, I have done a fair bit of testing (mostly on the train between home and work) and have confirmed that the behaviour for suspended apps is as I suspected at the end of the question. That is, your suspended app is woken up, you don’t receive any callbacks on your … Read more

Replacement for “purpose” property of CLLocationManager

The replacement for the purpose property in iOS 6 is a new Info.plist key named NSLocationUsageDescription (aka “Privacy – Location Usage Description”). The key is documented in the Information Property List Key Reference but unfortunately it’s not mentioned with the deprecation note of the purpose property. However, the CLLocationManager.h does have this comment: * Deprecated. … Read more

Reverse geocoding in Swift 4

CLGeocoder methods are asynchronous. What you would need a completion handler: import UIKit import CoreLocation import PlaygroundSupport PlaygroundPage.current.needsIndefiniteExecution = true func geocode(latitude: Double, longitude: Double, completion: @escaping (_ placemark: [CLPlacemark]?, _ error: Error?) -> Void) { CLGeocoder().reverseGeocodeLocation(CLLocation(latitude: latitude, longitude: longitude)) { placemark, error in guard let placemark = placemark, error == nil else { completion(nil, … Read more