我有两个kontakt.io信标。我可以使用AppStore中提供的默认Kontakt.io应用找到它。但是,当我使用SDK并尝试在我的自定义应用程序中找到它时,该应用程序请求蓝牙,这意味着它可以执行某些操作,但是找不到信标。
根据文档,我只必须创建一个KTKBeaconManager类的对象,分配一个KTKBeaconManagerDelegate并调用startFindingDevices方法。此后,只要范围内的设备发生更改,委托都应接收回调。我用一个名为BeaconManager的类扩展了KTKBeaconManager。这是它的代码(是的,我已经导入了所有内容并进行了代码编译。我没有在这里放置它以节省空间。)。
信标管理器
@interface BeaconManager : KTKBeaconManager <KTKBluetoothManagerDelegate>
@end
信标管理器
@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
开始搜索。
BeaconManager *beaconManager = [BeaconManager new];
[beaconManager startFindingDevices];
[beaconManager reloadDevices]; //Tells the manager to forget all devices and start searching again.
这实际上是文档中的示例代码,但是不起作用。任何人都在经历类似的事情并且知道该怎么办?
创建后,您的beaconManager很可能会被释放。您必须将其移动到实例变量。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句