This problem was encountered by me while research for chapter 7 of my book. Apparently other developers have encountered it as well as you can see from several questions on Stack Overflow:
- iOS 7 Ranging beacons: Sometimes ranging is Unavailable, and the only solution is reboot the device
- locationManager:rangingBeaconsDidFailForRegion:withError: kCLErrorDomain 16
- iBeacon: didRangeBeacons stops getting called, must reset device for it to work again
So I am filing this as a dupe hoping for it to be fixed in iOS 8. Or if not, that it will become more visible to Apple.
Filed as rdar://17003408 and on Open Radar.
Summary
If you have an app emit an iBeacon as well as ranging might fail with CLError code 16.
Steps to Reproduce
- Emit a beacon in an app via CBPeripheral
- Range it via CLLocationManager
Expected Results
- locationManager:didRangeBeacons:inRegion: should show this beacon
Actual Results
- sometimes it works
- sometimes you get locationManager:rangingBeaconsDidFailForRegion:withError: with code 16 “unavailable”.
Regression
I had this happen just now on an iPad Air and iPhone 5S, both running iOS 7.1.1. When I rebooted both the error no longer occurred.
Notes
In my testing I used separate apps on same device. i.e. start emitter app, then launch ranging app via Xcode. I am aware that beacon emitting is paused with the emitter app in background after a few seconds. Still ranging should not fail but return an empty array.
Supposedly earlier rdar://16761196 and rdar://15693657 describe the same issue.
Categories: Bug Reports