I am trying to find User's current location using Location Manager. Below is my code in viewdidload
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
//locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
if(IS_OS_8_OR_LATER)
{
[locationManager requestWhenInUseAuthorization];
[locationManager requestAlwaysAuthorization];
}
[locationManager startUpdatingLocation];
and in didUpdateLocations
self.userLocation = locations.lastObject;
if (userLocation != nil)
{
NSLog(@"sdsd %f %f", userLocation.coordinate.longitude, userLocation.coordinate.latitude);
[locationManager stopUpdatingLocation];
}
Am getting confirmation dialog and users location as set in simulation but not real time location even in device. I configured all settings in both device as well as xcode but still getting default location only.
Please let me know what should I do to get my realtime location and not simulation location?
The simulator does not receive your current location from the operating system. To debug you can select Debug->Location->City Bicycle Ride
in the simulator. This will simulate a bike ride around the block.
On the device it can take a while to get your current location if you are indoors. Turning on bluetooth and WIFI help iOS get a location faster.
Open your xCode
go to Product-> Scheme-> Edit
Scheme and then here inside Run
select Core location
and check the Allow location simulation
. May be it will work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.