LS_
LS_

Reputation: 7139

Scan for Kontakt.io iBeacons in background Objective-C

I'm trying to find how to scan for iBeacons in the background but as far as I understood you can only check when the user enters a region, I tried to enable Background Modes then I NSLog the 2 methods that should work in background:

    - (void)locationManager:(KTKLocationManager *)locationManager didEnterRegion:(KTKRegion *)region
    {
        NSLog(@"Enter region %@", region.uuid);
    }

    - (void)locationManager:(KTKLocationManager *)locationManager didExitRegion:(KTKRegion *)region
    {
        NSLog(@"Exit region %@", region.uuid);
    }

But the devices doesn't seem to scan while in background, what am I missing?

Upvotes: 1

Views: 619

Answers (1)

lukasz hlebowicz
lukasz hlebowicz

Reputation: 41

It's very simple to achieve with Kontakt.io SDK :) Just check this link http://docs.kontakt.io/ios-sdk/quickstart/#ios-8-compatibility. I believe you didn't add this to your plist. When you have it added then in your app after allowing to access your location by app, methods:

- (void)locationManager:(KTKLocationManager *)locationManager didEnterRegion:(KTKRegion *)region;
- (void)locationManager:(KTKLocationManager *)locationManager didExitRegion:(KTKRegion *)region

will be called and what is even more cool if you'll receive didEnterRegion then automatically will be called(few times) method:

- (void)locationManager:(KTKLocationManager *)locationManager didRangeBeacons:(NSArray *)beacons;

Of course how to extend background time etc. is a different topic ;)

Upvotes: 1

Related Questions