iOS 6 and Location Services not working
Asked Answered
V

8

7

I've updated my iOS SDK to version 6. After that I've compiled my app (works fine in iOS 4 & iOS 5) but now the location services doesn't work. My delegate isn't receiving any update and the upper location arrow is not appearing... I'm starting the service as the usual way:

[locationManager startUpdatingLocation];

My project is non ARC.

What is happening? This is driving me crazy...

Thanks in advance.

Veil answered 20/9, 2012 at 22:45 Comment(0)
L
6

Make sure you have a CFBundleDisplayName in your project's .plist file. Adding that key fixed it for me.

Landing answered 26/9, 2012 at 15:25 Comment(3)
Thanks so much! Why the hell one has anything to do with the other is beyond me. The docs say not even to include that property unless you are localizing.Staves
YEEEEEES!!!! This worked for me too... And following Phil, why the hell they are related to each other?Amaleta
I have no idea. Reading through docs I couldn't see anything that hints as to why its required for location.Landing
M
6

Just set the property pausesLocationUpdatesAutomatically of Location Manager to NO. This is a new feature of IOS 6 that disable Location Updates when application runs in background. The default value of this property is YES.

Miltiades answered 8/10, 2012 at 12:20 Comment(0)
S
4

This is a change in iOS6:

You need to implement locationManager:didUpdateLocations: instead of locationManager:didUpdateToLocation:fromLocation to be notified when the location is updated.

You should also read the documentation about startUpdatingLocation.

Stansbury answered 20/9, 2012 at 23:38 Comment(5)
Thanks for your advice. Now I'm using locationManager:didUpdateLocations: but it is never called. The location arrow isn't appearing... In iOS6 I can't see the app I'm developing in settings -> privacy -> location. Also, now sometimes I get this log: purgeIdleCellConnections: found one to purge conn = 0x1d5d2250. Sometimes not. Any clue? Thanks in advance!Veil
This might answer your question: #12520233Stansbury
I already have both bundle identifiers but the problem still remains :(Veil
What does [CLLocationManager authorizationStatus] say the status is?Olnee
This is not the solution, locationManager:didUpdateToLocation:fromLocation: is still valid, though deprecated in iOS 6 it still works.Weiner
P
1

In my case, I had the location manager under a different class and I was calling this class from the main controller. This was not working and the didUpdateLocations was not called.

//
//  LocationServices.h
// 

#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>

@interface LocationServices : NSObject <CLLocationManagerDelegate> {
    CLLocationManager *locationManager;

}

@property (nonatomic, retain) CLLocationManager *locationManager;

- (void)startLocationServices;

@end



//  LocationServices.m
#import "LocationServices.h"

@implementation LocationServices 
@synthesize locationManager, currentLocation;

- (void)startLocationServices {
    locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate = self;
    locationManager.pausesLocationUpdatesAutomatically = NO;
    locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;

    if ([CLLocationManager locationServicesEnabled]) {
        [locationManager startUpdatingLocation];

    } else {
        NSLog(@"Location services is not enabled");
    }
}

////////////////////////////////////////////////
- (void)locationManager:(CLLocationManager *)manager
     didUpdateLocations:(NSArray *)locations {
    CLLocation* location = [locations lastObject];
    NSLog(@"Updated: latitude %+.6f, longitude %+.6f\n",
          location.coordinate.latitude,
          location.coordinate.longitude);
}
@end

// Main controller
- (void)viewDidLoad {   
    [super viewDidLoad];

.....

LocationServices *locationSerices = [[LocationServices alloc]init];
[locationSerices startLocationServices];
......
}

The above code does not work. Why? I do not know ....you can easily lose interest when you spend so much time trying to do a thing that is supposed to be simple. iOS is very complicated and unfriendly programming environment. There are many ways to do one thing, only one works, you cannot mix and match without introducing a problem. You have to do everything by the book or you or you get nothing. Not even a hint that you did something wrong ... frustrating ...

Instead when I implemented locationManager:(CLLocationManager *)manager didUpdateLocations: in the main controller everything worked fine

Potamic answered 21/1, 2013 at 1:23 Comment(0)
F
0

The issue seems to be resolved in IOS 6.1 Beta2 - http://www.youtube.com/watch?v=aFZR0eMUV74

Faerie answered 16/11, 2012 at 19:19 Comment(0)
T
0

setting CFBundleDisplayName solved the problem for me. Same thing location update was never called, just set the info.plist parameter and it start working.

Thremmatology answered 27/2, 2013 at 2:29 Comment(0)
V
0

I've tried everything in plist files, cleans, rebuilds, new targets, configurations, etc, etc, etc. Nothing worked. But FINALLY I've fixed it. I had to create a new Xcode 4.5 project from scratch, reconfigure it, add file by file and framework by framework manually. It seems that my old XCode project had something internally incompatible with last XCode. I write this here because maybe it can save someone's next 10 hours of work.

Veil answered 28/2, 2013 at 12:9 Comment(0)
A
-4

Am I being too simplistic here? Under Privacy, Locations looks the same as it did in previous issues.What's all the fuss about?

Asymptomatic answered 22/9, 2012 at 18:12 Comment(1)
"Works for me" isn't the most helpful thing you could have added.Coldblooded

© 2022 - 2024 — McMap. All rights reserved.