Demystifying iBeacons@fbrunel
What is iBeacon?
iBeacon is an indoor positioning system
“a new class of low-powered, low-cost transmitters that
can notify nearby iOS 7 devices of their presence.”
What it is good for?
A whole new level of location awareness for
apps
An app will sense the presence of a beacon
and can react on it
trail markers in a park, exhibits in a museum, or
product displays in stores
How does it work?
A thin layer on top of CoreBluetooth exposed
via CoreLocation
Bluetooth LE has two core concepts
Devices can act as peripherals or centrals
Peripherals advertise services and expose
characteristics
Think of characteristics as object properties
Centrals scans for services; connects and
read/write characteristics
A beacon is a peripheral that advertise information
but it’s not a BLE service
Beacon CentralAd Ad Ad
Proximity UUID Major Minor Tx Power
Advertisement Packet
With that, an app can do 4 things
1. Scan for beacons identified with the same
proximity UUID
2. Detect if the device is in the region of one or more
beacons (~70m)
3. Determine the close proximity of a beacon
(ranging)
4. Use the minor/major integers to
differentiate beacons
Apple has built iBeacon in the CoreLocation API
Advertising a Beacon
NSUUID *proximityUUID = [[NSUUID alloc] initWithUUIDString:@"39ED98FF-2900-441A-802F-9C398FC199D2"]; CLBeaconRegion *beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:proximityUUID identifier:@"com.company.region"]; !NSDictionary *beaconPeripheralData = [beaconRegion peripheralDataWithMeasuredPower:@(-50)]; !CBPeripheralManager *peripheralManager = [[CBPeripheralManager alloc] initWithDelegate:self queue:nil options:nil]; [peripheralManager startAdvertising:beaconPeripheralData];
Monitoring Beacon Regions
NSUUID *proximityUUID = [[NSUUID alloc] initWithUUIDString:@"39ED98FF-2900-441A-802F-9C398FC199D2"]; CLBeaconRegion *beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:proximityUUID identifier:@"com.company.region"]; !self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.delegate = self; [self.locationManager startMonitoringForRegion:beaconRegion];
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region { [self.locationManager startRangingBeaconsInRegion:region]; } !- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region { [self.locationManager stopRangingBeaconsInRegion:region]; } !- (void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region { if ([beacons count] > 0) { CLBeacon *nearestExhibit = [beacons firstObject]; ! if (CLProximityNear == nearestExhibit.proximity) { [self presentExhibitInfo:nearestExhibit.major.integerValue]; } else { [self dismissExhibitInfo]; } } }
“One way to promote consistent ranging results
in your app is to use beacon ranging only while
your app is in the foreground.”
“if your app is in the foreground, it’s likely that the device is in the user’s hand.” — Apple BS Group.
Mythbusting
iBeacon
A. Beacons can be precisely located.
Wrong.
Location is really approximate due the signal strength and environment
factors
B. Beacons can push information.
Nope.
The app receives only a minor/major number.
It had to fetch information from the network or a local
database
iOS devices can’t be a beacon and a bluetooth service at the same time.
C. Beacon can be detected in background.
Meh.
Region monitoring changes happens between
4 and 15 minutes
Ranging doesn’t work in background. You have to
open your app.
D. A beacon can record who’s around.
What? No.
Beacons are just advertising, they are not aware of who’s listening
Ranging doesn’t work in background. You have to
open your app.
E. Beacon can do payments.
LOL. Stop it!
iBeacon is not enough, it’s just location
F. iBeacon works on other platforms.
Yes.
Support for Android exist via 3rd parties. iBeacon
profile has been documented
Not all is lost! It will improve but it’s still
radio technology.
Thanks.@fbrunel
Top Related