CoreLocation - region monitoring issue in iOS 7

875 views Asked by At

My code is working for iOS 6 . but problem is in iOS7 only didStartMonitoringForRegion getting called , didEnterRegion and didEExitRegion not getting called ....

- (void)viewDidLoad
{
    [super viewDidLoad];
    m_pLocatiomManager = [[CLLocationManager alloc] init];
    m_pLocatiomManager.desiredAccuracy = kCLLocationAccuracyBest;
    m_pLocatiomManager.delegate = self;
    [m_pLocatiomManager startMonitoringSignificantLocationChanges];
    [m_pLocatiomManager startUpdatingLocation];

}  

method to add region

if ([UIDevice currentDevice].systemVersion.floatValue >= 7.0) 
{
    float rad = 200;
    CLLocationCoordinate2D startLocation;
    startLocation.latitude = 12.9667 ;
    startLocation.longitude =77.5667 ;
    CLCircularRegion * reg1 = [[CLCircularRegion alloc] initCircularRegionWithCenter:startLocation radius:rad identifier:@"location"];
    [m_pLocatiomManager startMonitoringForRegion:reg1];
}
else
{
    float rad = 200;
    CLLocationCoordinate2D startLocation;
    startLocation.latitude = 12.9667;
    startLocation.longitude = 77.5667; 
    [m_pLocatiomManager startMonitoringForRegion:[[CLRegion alloc] initCircularRegionWithCenter:startLocation radius:rad identifier:@"location"]];
}

corelocation delegates ----

-(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{    
    NSLog(@"region entered %@",region.description);
}

-(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region
{
   NSLog(@"region exit  %@",region.description);
}

-(void)locationManager:(CLLocationManager *)manager didStartMonitoringForRegion:(CLRegion *)region
{
    NSLog(@"region monitoring stared");
}

Thanks .

1

There are 1 answers

3
Shaik Riyaz On BEST ANSWER

finally i solved this ....

- (void)viewDidLoad
{
    [super viewDidLoad];
    m_pLocatiomManager = [[CLLocationManager alloc] init];
    m_pLocatiomManager.desiredAccuracy = kCLLocationAccuracyBest;
    m_pLocatiomManager.delegate = self;
    [m_pLocatiomManager startMonitoringSignificantLocationChanges];
    [m_pLocatiomManager startUpdatingLocation];

}  

in method to add region . . .

if ([UIDevice currentDevice].systemVersion.floatValue >= 7.0) 
{
    float rad = 100;
    CLLocationCoordinate2D startLocation;
    startLocation.latitude = 12.9667 ;
    startLocation.longitude =77.5667 ;
    CLCircularRegion * reg1 = [[CLCircularRegion alloc] initWithCenter:startLocation radius:rad identifier:@"location"];
    [m_pLocatiomManager startMonitoringForRegion:reg1];
}
else
{
    float rad = 100;
    CLLocationCoordinate2D startLocation;
    startLocation.latitude = 12.9667;
    startLocation.longitude = 77.5667; 
    [m_pLocatiomManager startMonitoringForRegion:[[CLRegion alloc] initCircularRegionWithCenter:startLocation radius:rad identifier:@"location"]];
}