views:

102

answers:

1

I want Location based Reminder when user reaches to certain region

For that I have writen followin code

CLLocationManager *manager=[[CLLocationManager alloc] init];
manager.desiredAccuracy=kCLLocationAccuracyBest;

manager.delegate=self;

CLLocationCoordinate2D loc;

loc.latitude=LReminder.lat;

loc.longitude=LReminder.lon;

CLRegion *region=[[CLRegion alloc] initCircularRegionWithCenter:loc
radius:LReminder.accuracy dentifier:LReminder.title];

CLLocationAccuracy acc=1.0;

[manager startMonitoringForRegion:region desiredAccuracy:acc];

[manager startMonitoringSignificantLocationChanges];

And for the manager delegate

-(void)locationManagerCLLocationManager *)manager didEnterRegionCLRegion *)region
{

    NSLog(@"didEnterRegion for %@",region.identifier);

    UIAlertView *alr=[[UIAlertView alloc] initWithTitle:@"Reminder didEnterRegion" 
message:region.identifier delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Ok",nil];

    [alr show];

    [alr release];
}

-(void)locationManagerCLLocationManager *)manager didExitRegionCLRegion *)region
{
    NSLog(@"didExitRegion for %@",region.identifier);

    UIAlertView *alr=[[UIAlertView alloc] initWithTitle:@"Reminder didExitRegion" message:region.identifier delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Ok",nil];

    [alr show];

    [alr release];
}

Problem is when I reach to reminder location it is not calling any of the delegates' methods

please help me

A: 

Without knowing more, I can only guess, but I'm betting you're not using an iPhone 4. Region monitoring currently only works on the iPhone 4.

You should be using:

[CLLocationManager regionMonitoringEnabled]

to determine if your device can use region monitoring.

August
you should use [CLLocationManager regionMonitoringAvailable] to test if the device can use region monitoring accoring to doc
Grant M