问题
For StartMonitoring iBeacon my code is
-(void)startMonitoringForRegionWithUUID:(NSString*)UUID
{
CLBeaconRegion *beaconRegion= [[CLBeaconRegion alloc] initWithProximityUUID:[[NSUUID alloc] initWithUUIDString:UUID] identifier:UUID];
beaconRegion.notifyOnEntry = YES;
beaconRegion.notifyOnExit = YES;
beaconRegion.notifyEntryStateOnDisplay=YES;
//[self stopMonitoringForRegionWithUUID:UUID];
[self.locationManager startUpdatingLocation];
[self.locationManager startMonitoringForRegion:beaconRegion];
[self.locationManager startRangingBeaconsInRegion:beaconRegion];
}
-(void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region
{
NSLog(@"Number Of Beacons=%d",beacons.count); // show count for removed cell beacon too. there is no any other beacon with same UUID.
}
Above mentioned delegate methods show, false beacon. Even if, beacon battery is removed from beacon. Beacons array having present of those beacon. It happens when I run iPhone or iPad for almost 4-5 hours in beacon region.
After restarting device,when didRangeBeacon
callback happens it works fine. My question is, Why restarting does wonder? And what to do so I can avoid getting wrong beacon in callback method didRangeBeacons
?
Note:- i am using Kontak iBeacon.
来源:https://stackoverflow.com/questions/28164303/beacon-show-its-present-or-ranging-even-if-beacon-battery-is-removed-what-to