It's Very Easy.
First Write in your ViewDidload
Method To alloc CLLocationManager.
Here i set 50M distance .
locationManager = [[CLLocationManager alloc] init];
//there will be a warning from this line of code
[locationManager setDelegate:self];
//and we want it to be as accurate as possible
//regardless of how much time/power it takes
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
//set the amount of metres travelled before location update is made
[locationManager setDistanceFilter:50];
[locationManager requestAlwaysAuthorization];
[locationManager requestWhenInUseAuthorization];
[locationManager startUpdatingLocation];
So Every 50 Meter change Device This Method is called :
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
if (locations.count > 0) {
CLLocation *location = locations.lastObject;
User_latitude = [NSString stringWithFormat:@"%f",location.coordinate.latitude];
User_longitude = [NSString stringWithFormat:@"%f",location.coordinate.longitude];
NSLog(@"latitude = %f",location.coordinate.latitude);
NSLog(@"longitude = %f",location.coordinate.longitude);
[self webservice_UpdateLocation];
}
}