rangingBeaconsDidFailForRegion is getting called for 3 times

Hi,

I’m using only UUID to do ranging no major id or minor id

When user doesn’t authorise the use of location, rangingBeaconsDidFailForRegion is getting called 3 times, so the user is getting three alerts asking to update the settings.

see below for code, can you please let me what am i doing wrong ?

Init is called in viewdidload

startBeaconSearch is called in viewWillAppear

-(void) initBeacon{
    self.beaconManager = [[ESTBeaconManager alloc] init];
    self.beaconManager.delegate = self;
    self.beaconRegion = [[CLBeaconRegion alloc]
                         initWithProximityUUID:ESTIMOTE_PROXIMITY_UUID
                         identifier:@"xxxxx"];
}

- (void)startBeaconSearch{
    [self.beaconManager startRangingBeaconsInRegion:self.beaconRegion];
}


- (void)beaconManager:(ESTBeaconManager *)manager rangingBeaconsDidFailForRegion:(CLBeaconRegion *)region withError:(NSError *)error
{
    if(!manager.isAuthorizedForRanging){
        UIAlertView* errorView = [[UIAlertView alloc] initWithTitle:@"Authorization required.xxxxx !"
                                                        message:@"xxxxx"
                                                       delegate:self
                                              cancelButtonTitle:@"OK"
                                              otherButtonTitles:@"Settings",nil];
        [errorView show];
    }else{
        UIAlertView* errorView = [[UIAlertView alloc] initWithTitle:@"Unknown Location. xxxxx !"
                                                            message:@"xxxxxxx"
                                                           delegate:self
                                                  cancelButtonTitle:@"OK"
                                                  otherButtonTitles:@"Settings",nil];
        [errorView show];
    }
    
    
}

Thanks
Venkat

Solved it, when the app returns to foreground after user enables bluetooth, the UIApplicationWillEnterForegroundNotification observer method was getting called multiple times and i was calling the start ranging method in that method, this resulted in multiples calls.