我正在監視3個區域。 但是,即使應用程序在區域內,輸入區域和didexitregion方法也會重複觸發。我只需要在應用程序進入或退出任何3區域時才需要通知。出現這樣的情況,因爲我多次測試應用燈塔管理員didenter didexit區域方法反覆調用
這裏是我的代碼:
- (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;
}