iBeacon Development on iOS

Post on 23-Aug-2014

855 views 7 download

Tags:

description

Workshop summary: Overview about iBeacons and Bluetooth LE Region monitoring with iBeacons Proximity ranging with iBeacons New iBeacon features in iOS 8 Playing with the iBeacon infrastructure at Betahaus Common problems in working with iBeacons Slides from July 17th event at Betahaus Berlin.

Transcript of iBeacon Development on iOS

iBeacon Development on iOSOle Begemann

Agenda

Working with iBeacons on iOSExplore iBeacons at Betahaus

Discussion/Q&A

What are iBeacons?

Based on Bluetooth LEVery simplePassive

Advertising

Permanent Advertising100–500 ms intervalsBeacons donʼt see other devices

Range: 50-100 m (5–10 m indoors)

Beacons transmit 3 numbers

Proximity UUIDMajorMinor

Proximity UUID

010A6F6A-DD12-4B07-A56C-EBA3BCF7136A

Usually the same for all beacons in one installation

128 bits is enough to be globally unique

Major and Minor

0...65,535Configure in way that makes sense for your installation

www.open-location-berlin.com

iBeacon APIs

iBeacon APIs

Core Location (and not Core Bluetooth)

—Region Monitoring—Ranging

API is extremely simple

Region Monitoring

Region Monitoring

Detect when a beacon comes in or out of range

Monitor a single beacon or a group

Can be used in the background

Always Check Availability and Authorization

[CLLocationManager authorizationStatus]

[CLLocationManager isMonitoringAvailableForClass: [CLBeaconRegion class]]

CLBeaconRegion

identifierproximityUUIDmajorminor

notifyOnEntrynotifyOnExitnotifyEntryStateOnDisplay

Region Monitoring

NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@"F0018B9B-7509-4C31-A905-1A27D39C003C"];CLBeaconRegion *region = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:@"My Region"];];

[self.locationManager startMonitoringForRegion:region];

Region Monitoring: Delegate Methods

- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region

- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region

- (void)locationManager:(CLLocationManager *)manager monitoringDidFailForRegion:(CLRegion *)region withError:(NSError *)error

Region Monitoring

[self.locationManager stopMonitoringForRegion:region];

[self.locationManager requestStateForRegion:region];

Proximity Ranging

Ranging

Continuous updates (every second)

Monitor proximity and (estimated) distance

Does not work in the background

Check Availability

[CLLocationManager isRangingAvailable]

Proximity Ranging

[self.locationManager startRangingBeaconsInRegion:region];

[self.locationManager stopRangingBeaconsInRegion:region];

Proximity Ranging: Delegate Methods

- (void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region

- (void)locationManager:(CLLocationManager *)manager rangingBeaconsDidFailForRegion:(CLBeaconRegion *)region withError:(NSError *)error

CLBeacon

proximityUUIDmajorminor

proximityaccuracyrssi

proximity

CLProximityImmediate (centimeters)CLProximityNear (< 2–3 m)CLProximityFarCLProximityUnknown

accuracy

“Indicates the one sigma horizontal accuracy in meters. Use this property to differentiate between beacons with the same proximity value. Do not use it to identify a precise location for the beacon.”

Not a distance estimate!

rssi

Received signal strengthMeasured in decibels

Demos

MuseumUses ranging to display information about a piece of art when the associated beacon is in immediate or near proximity.

BEACONinsidegithub.com/beaconinside/BEACONinside-SDK-iOS

Uses the BEACONinside SDK(built on top of Core Location APIs)

oleb.net/files/ibeacon-workshop.zip

Common Problems

Region Monitoring

Region Exit is not immediate (15 seconds or more)

Enter and Exit events can take up to 15 minutes in the backgroundregion.notifyEntryStateOnDisplay = YES

http://developer.radiusnetworks.com/2013/11/13/ibeacon-monitoring-in-the-background-and-foreground.html

Ranging

Intermittent signal loss

Signal strength is not a reliable measure for distance

Apps should apply signal smoothing

Creating iBeacons

Turn your device into a beacon

CLBeaconRegion *region = [[CLBeaconRegion alloc] initWithProximityUUID:... major:... minor:... identifier:...]];NSDictionary *peripheralData = [region peripheralDataWithMeasuredPower:nil];self.peripheralManager = [[CBPeripheralManager alloc] initWithDelegate:self queue:nil];[self.peripheralManager startAdvertising:peripheralData];

Core Bluetooth

Core Bluetooth

Used to actively connect to Bluetooth LE devices

Devices offer services and characteristics

Not required for iBeacons, but many iBeacons offer additional functionality via Core Bluetooth

Agenda

Working with iBeacons on iOSExplore iBeacons at Betahaus

Discussion/Q&A

Agenda

Working with iBeacons on iOSExplore iBeacons at Betahaus

Discussion/Q&A

Limitations on iOS

Scanning for beacons with unknown UUIDs is not possible

App Store Policy

Not permitted to expose UUIDs to users

Makes it difficult to write apps that work with the userʼs own beacons

Documentation

developer.apple.com/ibeacon/

Thank you@olebegemann

ole@oleb.net

oleb.net