Beacon manager dienter didexit 区域方法被重复调用

Beacon manager didenter didexit region methods are repeatedly called

我正在监控 3 个区域。 但是,即使应用程序在该区域内,也会重复触发 didenter region 和 didexitregion 方法。仅当应用程序进入或退出 3 个区域中的任何一个时,我才需要通知。发生这种情况是因为我正在反复测试该应用程序吗

这是我的代码:

- (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;
}

这是由于之前安装的应用程序的区域实例。

重启设备后该问题就会消失

您应该重新启动您的设备。

在iOS中,OS存储了20个区域实例。我认为它不断地将区域实例放入 OS 区域数组中。你应该用一些随机区域填充数组,或者你应该在每次测试后重新启动你的设备。