You need to keep track of the times each beacon was detected in your didRangeBeaconsInRegion
method and ignore certain beacons using a software filter if they have been seen recently.
An example of how to do this is shown here. The core of that is:
- (void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLRegion *)region
{
for (CLBeacon *beacon in beacons) {
Boolean shouldSendNotification = NO;
NSDate *now = [NSDate date];
NSString *beaconKey = [NSString stringWithFormat:@"%@_%ld_%ld", [beacon.proximityUUID UUIDString], (long) beacon.major, (long) beacon.minor];
NSLog(@"Ranged UUID: %@ Major:%ld Minor:%ld RSSI:%ld", [beacon.proximityUUID UUIDString], (long)beacon.major, (long)beacon.minor, (long)beacon.rssi);
if ([beaconLastSeen objectForKey:beaconKey] == Nil) {
NSLog(@"This beacon has never been seen before");
shouldSendNotification = YES;
}
else {
NSDate *lastSeen = [beaconLastSeen objectForKey:beaconKey];
NSTimeInterval secondsSinceLastSeen = [now timeIntervalSinceDate:lastSeen];
NSLog(@"This beacon was last seen at %@, which was %.0f seconds ago", lastSeen, secondsSinceLastSeen);
if (secondsSinceLastSeen < 3600*24 /* one day in seconds */) {
shouldSendNotification = YES;
}
}
if (shouldSendNotification) {
[self sendLocalNotification];
}
}
}