AprilBeaconSDK Background mode

How to make AprilBeaconSDK to work in background mode (Uses Bluetooth LE accessories)? I believe April beacons in tandem with AprilBeaconSDK also provides data when the app is in background state (i.e. minimized pressing home button). How to implement this scenario using the AprilBeaconSDK?

AprilBeaconSDK, requestAlwaysAuthorization (for background location) call on ABBeaconManager is needed before starting location updates.

There also needs to be NSLocationAlwaysUsageDescription key in Info.plist with a message to be displayed in the prompt.

Thanks for your quick response brother.

I have the NSLocationAlwaysUsageDescription key in the Info.plist.

I am doing this:
if ([UIApplication instancesRespondToSelector:@selector(requestAlwaysAuthorization)]) {
CLLocationManager * locationManager = [[CLLocationManager alloc] init];
[locationManager requestWhenInUseAuthorization];
}

Am I doing it right or it won’t work???

What do you mean by “requestAlwaysAuthorization (for background location) call on ABBeaconManager is needed before starting location updates.”??? Can you explain how to requestAlwaysAuthorization call on ABBeaconManager???

In this method, you can do it.

  • (void)beaconManager:(ABBeaconManager *)manager
    didEnterRegion:(ABBeaconRegion *)region
    {
    [_beaconManager startRangingBeaconsInRegion:region];
    }
    If the callback didExitRegion method, distance is -1.

Thank you for that. It worked. Now I can get the method didEnterRegion and didExitRegion working.

Hi markss,

I had another query. Our client has a requirement to notify the user when the user moves away beyond a specific distance from the beacon. Even when the app is in background.

Till what I have understood, didRangeBeacons: method won’t be called when app in background. So we won’t get the distance. didEnterRegion: / didExitRegion: Only these 2 methods from the entire SDK will run in background. So that means I won’t be able to receive the distance when app is in background. Am i right or is their any workaround to implement this scenario???

In didEnterRegion method, you can do it.

- (void)beaconManager:(ABBeaconManager *)manager
       didEnterRegion:(ABBeaconRegion *)region
{
    [_beaconManager startRangingBeaconsInRegion:region];
}

If the callback didExitRegion method, distance is -1. the beacon proximity is CLProximityUnknown.