关于iBeacons的一些东西
来源:互联网 发布:英格兰长弓手—指算法 编辑:程序博客网 时间:2024/04/30 09:03
iBeacons是iOS7的新增的功能,可用于室内近场定位。iOS设备可以检测到附近的iBeacons兼容设备(是设备检测iBeacons),在当前版本中甚至可以在应用未打开的情况(就是后台)下获得回调(很nb)。
iBeacons有一个有用的特性是可以距离感应,当你的iOS设备检测到了一个iBeacons设备,那么app即可通过CoreLocation监测设备的距离,通过回调的形式通知距离变化(一般不会大于100m)
前提就是用户必须开启BLE4.0(屌丝跟高富帅开始区分了,我是屌丝iPhone4)其中支持的设备(iPhone 4s, iPod Touch5, iPad3及之后的设备)所有支持低功耗蓝牙技术(BLE4.0)就是的iOS设备都可以变成一个iBeacon设备
首先需要定义一个CLBeaconRegion来实现iBeacon,如下
NSUUID *myProximityUUID = [[NSUUID alloc] initWithUUIDString:@"566C5595-6EC7-4F08-909F-C954BDCA6CD3"];NSNumber *branchNumber = @42;NSNumber *tillNumber = @3;CLBeaconRegion *region = [[CLBeaconRegion alloc] initWithProximityUUID:myProximityUUID major:[branchNumber unsignedShortValue] minor:[tillNumber unsignedShortValue] identifier:@"com.mycompany.store"];
然后把这些信息交由CBPeripheralManager进行广播
NSDictionary *peripheralData = [region peripheralDataWithMeasuredPower:nil];CBPeripheralManager *myPeripheralManager = [[CBPeripheralManager alloc] initWithDelegate:self queue:nil];[myPeripheralManager startAdvertising:peripheralData];
- (void)peripheralManagerDidUpdateState:(CBPeripheralManager *)peripheral
{
NSLog(@"hello");
switch (peripheral.state) {
case CBPeripheralManagerStatePoweredOn:
//[self setupService];
break;
default:
NSLog(@"Peripheral Manager did change state");
break;
}
}
于是一个iOS设备就变成了一个iBeacon了
内容来自某人的栖息地
- 关于iBeacons的一些东西
- 关于player的一些东西
- 关于Rss的一些东西
- 关于招聘的一些东西
- 关于log4j的一些东西
- 关于memset的一些东西
- 关于电子邮件的一些东西
- 关于sscanf的一些东西
- 一些关于hibernate的东西
- 关于emacs的一些东西
- 关于javaScript的一些东西
- 关于wlan的一些东西
- 关于bsp的一些东西
- 关于补码的一些东西
- 关于友元类的一些东西
- 关于一些语法的东西
- 关于UIPageControl的一些东西
- 关于EHCI的一些东西
- hypervisor&VDI_IN_A_BOX
- Oracle中的Union、Union All、Intersect、Minus
- mysql中key 、primary key 、unique key 与index区别
- 迭代器模式(Iterator pattern)
- JS动态调用方法名
- 关于iBeacons的一些东西
- LeetCode 之 Longest Consecutive Sequence
- MATLAB卡方检验精度问题解决办法(算的就是卡方检验下的P值)
- oracle中的数据库、用户、方案、表空间、表对象之间的关系
- java五种内部排序(直接插入排序、希尔排序、快速排序、堆排序、归并排序)
- 关于求模与求余
- rails simple_form
- WPF 样式
- Windows多屏幕操作实践