MABeaconReceiver 允许您以轻量级的方式连接到 iBeacon,而无需依赖 iBeacon 制造商提供的 SDK。
#import "MABeaconReceiver.h"
然后创建一个属性
@property (strong, nonatomic) MABeaconReceiver *beaconReceiver;
遵守协议
MABeaconReceiverDelegate
设置接收器
self.beaconReceiver = [[MABeaconReceiver alloc] initWithUUID:kUUID bundleID:kBundleID];
self.beaconReceiver.delegate = self;
实现函数
-(void)foundBacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region
NSSortDescriptor *nearestSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"rssi" ascending:YES];
NSArray *sortedBeacons = [beacons sortedArrayUsingDescriptors:@[nearestSortDescriptor]];
//This is the nearest beacon
CLBeacon *beacon = [sortedBeacons lastObject];
}
Mohit Athwani, [email protected]
MABeaconReceiver 采用 MIT 许可证。有关更多信息,请参阅 LICENSE 文件。