Reputation: 143
I have two kontakt.io Beacons. I'm able to find it using the default Kontakt.io app available in the AppStore. But when I use the SDK and try to find it in my custom app, the app requests Bluetooth, which means it does something with it, but no beacons are found.
According to the documentation I must only create an object of KTKBeaconManager class, assign a KTKBeaconManagerDelegate and call startFindingDevices method. After that the delegate should receive callbacks whenever devices in range changes. I extended the KTKBeaconManager with a class called BeaconManager. Here's its code (Yes I have imported everything and code compiles. I didn't put it here to save space.).
BeaconManager.h
@interface BeaconManager : KTKBeaconManager <KTKBluetoothManagerDelegate>
@end
BeaconManager.m
@implementation BeaconManager
- (instancetype)init
{
self = [super init];
if (self) {
//Setting the delegate to self
self.delegate = self;
}
return self;
}
- (void)bluetoothManager:(KTKBluetoothManager *)bluetoothManager didChangeDevices:(NSSet *)devices {
NSLog(@"Entered didChangeDevices. Devices size: %d", devices.count);
}
@end
Starting the search.
BeaconManager *beaconManager = [BeaconManager new];
[beaconManager startFindingDevices];
[beaconManager reloadDevices]; //Tells the manager to forget all devices and start searching again.
This is actually a sample code from the documentation, but it's not working. Anybody's going through something similar and has got a clue what to do?
Upvotes: 0
Views: 582
Reputation: 41
It's not written that directly but you should know what's the scope of life for object - it should be a property if you want to have it working all the time etc.
Upvotes: 0
Reputation: 36
Your beaconManager is most probably deallocated just after it's created. You have to move it to an instance variable.
Upvotes: 2