How to start ranging beacons on first Application start after authorisation is given

I have the Estimote SDK implemented in an existing project, but am running into a problem.
When the application first starts, and starts to search for beacons, it asks authorisation. When given however scanning of beacons still does not start. I have to completely kill the App and start again before it works.

Neither is the delegate

- (void) beaconManager:(id)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status

is never called the first time.

Another observation is that this same delegate is called each time the app start subsequently, which seems not right to me, as there is no change in the authorisation status (at least not on an higher level).

You need to call the requestAlwaysAuthorization (or the “when in use” counterpart) every single time before you start ranging/monitoring, not just the first time the app is launched. It will trigger the popup the very first time it is called, but it’s still required by iOS to keep calling it after that whenever you initialize the ESTBeaconManager anew.

Looking at the code snippet you posted in this thread, I’d suggest to try changing:

if ([ESTBeaconManager authorizationStatus] == kCLAuthorizationStatusNotDetermined)
{
    [self.beaconManager requestAlwaysAuthorization];
    [self initialiseRanging];
}
else if([ESTBeaconManager authorizationStatus] == kCLAuthorizationStatusAuthorized)
{
            [self initialiseRanging];
}

… to a simple:

[self.beaconManager requestAlwaysAuthorization];

… and move the if/else checks and initialiseRanging into the didChangeAuthorizationStatus method. This is a more idiomatic way to perform the authorization checks.

Ok, that is no problem, however, it is the first time that is the problem. When I get the authorisation question ranging does not start (neither is the delegate called). I think it was with the CLLocationManager, but cannot say the 100% for certain as during development I don’t reinstall the application that often, and probably never to test the beacon component straight away.

But currently the only way to get the system working is to launch the App, accept authorisation, kill the App completely and restart, and this obviously is not an option for users who want to use it as soon as they download it.