iBeacon Not Working in iOS 8

If you are unsuccessful in getting one of the many iBeacon examples working in iOS 8 here is why.

Apple has changed the Core Location Manager and it will fail silently now in iOS 8. Hard to believe a public API would fail silently and not notify the developer but it is true. I lost a couple of hours and gained some grey hairs trying to figure this one out.

The first thing you will need to do is add the key NSLocationAlwaysUsageDescription to your Info.plist. Make sure it is a String and give it a value. The value can be whatever you want to be displayed to inform the user when they are prompted for location permssions.

Next add the following code. You will want to add it in the same method where your init the Location Manager like I have below.

1
2
3
4
5
6
7
8
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;

// Check for iOS 8. If you don't have this check the app will crash with "unknown selector" in iOS 7.
if ([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)])
{
  [self.locationManager requestAlwaysAuthorization];
}

That is it. You iBeacon code should now work.