How to trigger alert for multiple monitored regions?


#1

Hi there,

I’m trying to figure out how to trigger different alerts for different monitored regions on the iphone. I know how to set up monitored regions and start monitoring…

    //Monitoring a Region
    CLLocationCoordinate2D layerCoords =
    CLLocationCoordinate2DMake(53.385909, -6.260067);
    CLRegion *layerRoom = [[CLRegion alloc]
            initCircularRegionWithCenter:layerCoords
                                  radius:100
                            identifier:@"layerRoom"];
    
    
    // Start monitoring for our CLRegion using best accuracy
    [locationManager startMonitoringForRegion:layerRoom
                desiredAccuracy:kCLLocationAccuracyBest];

but I’m not quite sure how to set up different alerts for each region once they are entered. Currently, I’m using the didEnterRegion: method to trigger the alert but I only know how to do that once.

//Setting up alerts for when region is entered

  • (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region {

    UIAlertView *locationAlert = [[UIAlertView alloc]
    initWithTitle:@“Success!” message:@“You have arrived!” delegate:nil cancelButtonTitle:@“OK” otherButtonTitles:nil];

    [locationAlert show];

}

Can somebody help? I’m a total newbie. Thanks very much in advance!


#2

Pure speculation, haven’t looked at the API at all, but judging by the fact that locationManager:didEnterRegion: takes a region as argument, you should be able to determine the region by examining that parameter and deciding what to do next.

Or am I overlooking something?