iOS - Connecting to beacons in the background

I am currently creating an application that requires background access to the beacons temperature sensors.

To attempt to achieve this, I am currently monitoring in the background (when the app is closed / device is locked). This notifies the application when I enter the beacon region I wish to range. I then extend my background processing time by using the 'beginBackgroundTaskWithName' method, this gives me three extra minutes. I can then range and detect the beacons in the region.

This so far works perfectly fine, but when I attempt to connect to these beacons I encounter an issue.

If the ESTConfig is set incorrectly at the time, it works as intended, sending me a "You are not authorized to access this beacon" message.

But when the ESTConfig is set correctly, the connection takes a very long time, finally responding with: 'Error Domain=EstimoteDomain Code=404 "Peripheral not found"'

Does anyone know what this error message means, how to fix it, or an alternate solution? As without knowing the issue I am quite stuck :(

Thanks in advance for any help :)

Hey Jordan,

Yeah, connecting to the beacon in the background is a bit tricky due to iOS restrictions on what you can do with Core Bluetooth when in the background. Our workaround so far was to discover a reference to the CBPeripheral when the app's still in the foreground, and then use it to connect in the background. We're already working on some changes to the SDK and beacon firmware that'll streamline the process. I'll keep you posted.

Hi Piotr,

Thank you very much for the advice. I've tried this solution and it seems to be working :)