5

I have read CLLocationManager kCLErrorDomain Codes? as well as Apple Docs

I check to make sure ranging is available before calling startRangingBeaconsInRegion: and I am also checking if ranging is available while in the locationManager:rangingBeaconsDidFailForRegion:withError: method. Returns true both times.

When I get the set of monitoredRegions, my beacon is in the set (so registering for monitoring is working).

I have read that error 16 can mean ranging is unavailable, bluetooth could be off, location services could be off, airplane mode could be on, I have checked them all and all are available and running (obviously not in airplane mode).

What could be causing the ranging to fail, every time I run the app?

Community
  • 1
  • 1
akl
  • 53
  • 1
  • 4

3 Answers3

7

It seems that I started to face this issue after I updated my device to iOS 7.1 (iPhone 5S). rangingBeaconsDidFailForRegion: gets called with error.domain equal to @"kCLErrorDomain" and with error.code as kCLErrorRangingUnavailable (16) (even though Airplane mode is not on and Bluetooth is up and running).

I followed davidgyoung's advice to just boot (I did a hard boot pressing Home + Power until the device shuts down and displays the Apple logo, but also a normal boot works) the device, and now it seems to work correctly.

This appears to be a bug in iOS 7.1 and iOS 7.1.1, see here https://stackoverflow.com/a/22949187/1461050. The only workaround - for now - is to reboot the device.

Apple has now released iOS 7.1.2, which should fix this problem (awaiting for confirmation).

Community
  • 1
  • 1
Markus Rautopuro
  • 7,997
  • 6
  • 47
  • 60
  • Hi Markus, great find. Thanks for the suggestions. Did help me too – decades Mar 28 '14 at 22:13
  • 1
    Hi there, it really works after rebooting; but does it also work after several days? – Paradise Apr 03 '14 at 02:17
  • Well no. For some reason it goes to that mode at least with my iPhone 5S (7.1). I need to dig further into this, I might be doing something wrong with the initialization. – Markus Rautopuro Apr 04 '14 at 06:02
  • I have this issue daily. This isn't a sustainable solution for production if my app relies on iBeacon. I can't expect my users to restart their devices all the time. Is anyone else regularly encountering this error and know of another fix? Also worth noting: ranging fails across all iBeacon apps at this point, not just mine. – Ted Avery Apr 08 '14 at 23:58
  • I´m seeing the same problem as well. I just talked to a customer with error 16, rebooting helped to fix his iPad3. But I´ve also had my hands on an iPhone5 with no error, but the ranging API broken. And another customer with kCLErrorFomain Code=5, rebooting did help in all cases. Well except for one phone, which has a broken on/off button, so rebooting is not an option :( – volkersfreunde Apr 14 '14 at 16:31
3

Just to eliminate any possibility that it could be something in your code, try a reference app like my Locate for iBeacon. If it also does not work, you probably have an OS or hardware problem.

To troubleshoot this, first reboot your phone and try again. Then try pairing to a regular Bluetooth device (headphones, Mac, etc). If regular Bluetooth pairing works, it may be a Bluetooth LE issue.

Your iOS device must be either an iPhone 4s+ or an iPad 3+ (needed for BLE).

davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • I do see my iBeacon (although it has a different UUID) when using BLE scanners. I am able to use the bluetooth on my device (iPhone 5S), I connect to headphones. What I hadn't considered is that I am running 7.1 beta, guess I'll have to check on a different phone. – akl Jan 03 '14 at 17:03
  • 3
    After following ALL your steps, I seem to have fixed most of my issue...when all else fails, fall back on Windows/Microsoft mentality and reboot – akl Jan 03 '14 at 17:16
  • Why is this marked as the correct answer: you certainly cannot expect the users to restart their devices every once-and-a-while to get beacon scanning to work properly? – Markus Rautopuro Apr 16 '14 at 13:22
  • 1
    Unfortunately no better solution is known at this time. This appears to be a newly introduced bug in iOS 7.1. See here: http://stackoverflow.com/a/22949187/1461050 – davidgyoung Apr 16 '14 at 13:58
  • I got a response from Apple yesterday, see below **Edit4**. – Markus Rautopuro Jun 05 '14 at 17:14
1

The problem is closely related to the CoreBluetooth Unknown Error 1309.

In some circumstance, seems that the CoreBluetooth Stack become corrupted and the only solution is to reboot the device.

There're plenty of users that are reporting such behaviour. We've fired a bug to Apple Radar and we're waiting for response.

You can also report the problem to Apple Radar so that they will notice this bug.

valvoline
  • 7,737
  • 3
  • 47
  • 52