НШ,Почему Геозоны отслеживание с использованием методов делегирования Cllocationmanager не призывающих
Я реализовал Geo изгороди с помощью менеджера местоположения.
Здесь я создаю регионы
введите код здесь
С учетом же нагрузки я создать объект как
// для Геозоны отслеживания
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.distanceFilter = kCLLocationAccuracyBest;
[locationManager startMonitoringSignificantLocationChanges];
[locationManager startUpdatingLocation];
-(void)TraceGeofenceLocation{
for (int k=0; k< [self.chGeofenceType count]; k++) {
NSString *chTracLati = [NSString stringWithFormat:@"%f",[[self.chGeofenceLatitudes objectAtIndex:k] doubleValue]];
NSString *chTracLong = [NSString stringWithFormat:@"%f",[[self.chGeofeceLongitudes objectAtIndex:k] doubleValue]];
NSString *chTracRadius = [NSString stringWithFormat:@"%f",[[self.chGeofenceRadius objectAtIndex:k] doubleValue]];
CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(chTracLati.doubleValue, chTracLong.doubleValue);
if ([[self.chGeofenceType objectAtIndex:k] intValue] == 1) {
region = [[CLRegion alloc]initCircularRegionWithCenter:coord radius:chTracRadius.doubleValue identifier:@"Restricted"];
}
else if ([[self.chGeofenceType objectAtIndex:k] intValue] == 2){
region = [[CLRegion alloc]initCircularRegionWithCenter:coord radius:chTracRadius.doubleValue identifier:@"SafeZone"];
}
else{
region = [[CLRegion alloc]initCircularRegionWithCenter:coord radius:chTracRadius.doubleValue identifier:@"Curfew"];
}
[region setNotifyOnEntry:YES];
[region setNotifyOnExit:YES];
[locationManager startMonitoringForRegion:region desiredAccuracy:kCLLocationAccuracyBest];
}
}
Я тестировал в моем делегатом методы, если какой-либо регион он войдет или нет.
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
locationnew = locations.lastObject;
self.Latit=[NSString stringWithFormat:@"%f", locationnew.coordinate.latitude];
self.Longi=[NSString stringWithFormat:@"%f",locationnew.coordinate.longitude];
Speed = [[NSString stringWithFormat:@"%f",[locationnew speed]] floatValue];
NSLog(@"Speed :%f Latitude :%@ Longitude :%@",Speed,self.Latit,self.Longi);
}
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
if ([region.identifier isEqualToString:@"Restricted"]) {
[self sendNotificationtoServerwithtype:@"1"];
}
else if ([region.identifier isEqualToString:@"Curfew"]){
[self sendNotificationtoServerwithtype:@"3"];
}
}
-(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region {
if ([region.identifier isEqualToString:@"SafeZone"]){
[self sendNotificationtoServerwithtype:@"2"];
}
}
- (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region
{
if (state == CLRegionStateInside){
NSLog(@"is in target region");
}else{
NSLog(@"is out of target region");
}
}
Моего метод делегат местоположение обновление вызывает, и я получаю в консоли, но войти в регион, выход из регионов и сделал DetermineState не зовут ...
Может кто-нибудь мне помочь.
Заранее спасибо