我正在监视 3 个区域。但是即使应用程序在该区域内,也确实会重复触发进入区域和 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;
}