0
votes

I am trying to get a sample application working for iBeacon scanning and display.

This is using iOS 8 and the target device is iPhone 5s. Following pre-requisites are taken care before running the application in iPhone 5s.

1) Added NSLocationAlwaysUsageDescription in info.plist 2) iOS is selected as 8 3) Setting in Xcode, on the "Capabilities" tab, under "Background Modes", where "Location Updates" and "Uses Bluetooth LE Accessories" are selected. 4) Background App Refresh is ON in iPhone.

Unfortunately, didEnterRegion and didRangeBeacons are not getting called at all. However, didStartMonitoringForRegion gets called.

Please also note the following.

1) All the beacons are working fine and verified in the same iPhone using third party application downloaded. 2) In the debug window, I can always see that Location Service authorization status is "Not determined" always. 3) If I switch location services off in iPhone, then I get authorization status as "Denied". 4) [self.locationManager requestAlwaysAuthorization]; call has no effect.

What is that I am not doing it correctly ? It would be really great if you can help me resolve this issue.

2
Off topic: once you get your problem resolved, make sure to disable the Background Modes. They're not required for beacon monitoring to wake the app into the background (the "always" authorization is), and that (using bg modes when not needed) will get your app rejected during the review process. - heypiotr

2 Answers

0
votes

It's certainly frustrating when this happens, because it is unclear what is the root cause. The key is that you need to get the authorization status to be accepted.

Three things I would try:

  1. Make sure you have a string in your .plist file for NSLocationAlwaysUsageDescription. If this is not present, the user will not be prompted to give permission for location services.

    <key>NSLocationAlwaysUsageDescription</key>
    <string>Need to use location services</string>
    
  2. Go in to Settings for your application and looks for a location services switch. Try to use that to enable the permission.

  3. If the above fails to solve the problem, try uninstalling and-reinstalling the app. I have seen an app get into a bad state during development where this is the only way you can get iOS to re-prompt for authorization.

0
votes

The issue is resolved.

I was making a mistake of editing the info.plist file in the Test Directory instead of editing the info.plist file in "Supporting Files" Directory.

Once I added NSLocationAlwaysUsageDescription in the info.plist in "Supporting Files" Directory, everything worked fine.