Reputation: 617
I’ve a problem about iBeacon monitoring implementation. I fire a local notification when locationManager:didDetermineState:forRegion: method is called. When application goes in background I don’t get any local notification at all but they came all at once when I active the screen pushing the home button. According to time I leave sleep the device I can get up to tens notification always when I wake it up. How is that possible? Anyone had the same problem?
I use iPhone 5S and 5C with iOS 7.1. The local notification is set in this way:
- (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region{
UILocalNotification *localNot = [[UILocalNotification alloc] init];
localNot.alertBody = [NSString stringWithFormat:@"Region state %d determined", state];
localNot.alertAction = @"Go for it!";
localNot.soundName = UILocalNotificationDefaultSoundName;
localNot.fireDate = nil;
[[UIApplication sharedApplication] presentLocalNotificationNow:localNot];
}
Upvotes: 1
Views: 475
Reputation: 64941
I suspect that you are not actually doing any background detections at all, and the reason you see the notifications when you hit the home button is because you have the notifyEntryStateOnDisplay
flag set, which causes you to get an extra callback to didDetermineState: forRegion:
whenever the screen comes on, for every region you are monitoring with the flag set.
Why do you not get callbacks in the background? You may need to wait up to 15 minutes to detect an iBeacon in the background, even on iOS 7.1. See here.
Upvotes: 1