iosobjective-cclbeaconregion

Beacon manager didenter didexit region methods are repeatedly called


I am monitoring 3 regions . But did enter region and didexitregion methods are repeated triggered even though app is inside the region. I need notifications only when app enters or exits any of the 3 region. Is this happening because i am testing the app repeatedly

Here is my code:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {


STCloudManager setupAppID:@"valid is" andAppToken:@"valid token"];    


    UILocalNotification *locationNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];

    if (locationNotification) {
        // Set icon badge number to zero
        application.applicationIconBadgeNumber = 0;
    }

    self.beaconManager1= [[ESTBeaconManager alloc]init];
    self.beaconManager1.delegate = self;
    self.beaconManager1.avoidUnknownStateBeacons=YES;
    self.beaconManager1.preventUnknownUpdateCount=YES;
    NSSet *set=[self.beaconManager1 monitoredRegions];
    self.region_desk=[[CLBeaconRegion alloc]
                      initWithProximityUUID:ESTIMOTE_PROXIMITY_UUID major:36798 minor:29499
                      identifier:@"Appdelegate_Desk_Beacon_Region"];

    self.region_door1=[[CLBeaconRegion alloc]
                       initWithProximityUUID:ESTIMOTE_PROXIMITY_UUID major:29666 minor:63757
                       identifier:@"Appdelegate_Door_Beacon1_Region"];

    self.region_door2=[[CLBeaconRegion alloc]

  initWithProximityUUID:ESTIMOTE_PROXIMITY_UUID major:64157 minor:33188
                       identifier:@"Appdelegate_Door_Beacon2_Region"];


    [self.beaconManager1 requestAlwaysAuthorization];


    //already monitoring
    if ([set count]<3) {

        if (![set containsObject:self.region_desk]) {

             [self.beaconManager1 startMonitoringForRegion: self.region_desk];
        }

        //
        if (![set containsObject:self.region_door1]) {

              [self.beaconManager1 startMonitoringForRegion: self.region_door1];
        }
        if (![set containsObject:self.region_door2]) {

            [self.beaconManager1 startMonitoringForRegion: self.region_door2];
        }




    }



    return YES;
}

Solution

  • You should restart your device.

    In iOS 20 region instances are stored by the OS. I think it is continuously putting the region instances into that OS region array. you should fill the array with some random region or you should restart your device after each test.