ibeacon development on ios
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
![Page 1: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/1.jpg)
iBeacon Development on iOSOle Begemann
![Page 2: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/2.jpg)
Agenda
Working with iBeacons on iOSExplore iBeacons at Betahaus
Discussion/Q&A
![Page 3: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/3.jpg)
What are iBeacons?
![Page 4: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/4.jpg)
Based on Bluetooth LEVery simplePassive
![Page 5: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/5.jpg)
Advertising
Permanent Advertising100–500 ms intervalsBeacons donʼt see other devices
Range: 50-100 m (5–10 m indoors)
![Page 6: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/6.jpg)
Beacons transmit 3 numbers
Proximity UUIDMajorMinor
![Page 7: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/7.jpg)
Proximity UUID
010A6F6A-DD12-4B07-A56C-EBA3BCF7136A
Usually the same for all beacons in one installation
128 bits is enough to be globally unique
![Page 8: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/8.jpg)
Major and Minor
0...65,535Configure in way that makes sense for your installation
![Page 10: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/10.jpg)
![Page 11: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/11.jpg)
iBeacon APIs
![Page 12: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/12.jpg)
iBeacon APIs
Core Location (and not Core Bluetooth)
—Region Monitoring—Ranging
API is extremely simple
![Page 13: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/13.jpg)
Region Monitoring
![Page 14: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/14.jpg)
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
![Page 15: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/15.jpg)
Always Check Availability and Authorization
[CLLocationManager authorizationStatus]
[CLLocationManager isMonitoringAvailableForClass: [CLBeaconRegion class]]
![Page 16: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/16.jpg)
CLBeaconRegion
identifierproximityUUIDmajorminor
notifyOnEntrynotifyOnExitnotifyEntryStateOnDisplay
![Page 17: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/17.jpg)
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];
![Page 18: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/18.jpg)
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
![Page 19: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/19.jpg)
Region Monitoring
[self.locationManager stopMonitoringForRegion:region];
[self.locationManager requestStateForRegion:region];
![Page 20: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/20.jpg)
Proximity Ranging
![Page 21: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/21.jpg)
Ranging
Continuous updates (every second)
Monitor proximity and (estimated) distance
Does not work in the background
![Page 22: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/22.jpg)
Check Availability
[CLLocationManager isRangingAvailable]
![Page 23: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/23.jpg)
Proximity Ranging
[self.locationManager startRangingBeaconsInRegion:region];
[self.locationManager stopRangingBeaconsInRegion:region];
![Page 24: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/24.jpg)
Proximity Ranging: Delegate Methods
- (void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region
- (void)locationManager:(CLLocationManager *)manager rangingBeaconsDidFailForRegion:(CLBeaconRegion *)region withError:(NSError *)error
![Page 25: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/25.jpg)
CLBeacon
proximityUUIDmajorminor
proximityaccuracyrssi
![Page 26: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/26.jpg)
proximity
CLProximityImmediate (centimeters)CLProximityNear (< 2–3 m)CLProximityFarCLProximityUnknown
![Page 27: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/27.jpg)
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!
![Page 28: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/28.jpg)
rssi
Received signal strengthMeasured in decibels
![Page 29: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/29.jpg)
Demos
![Page 30: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/30.jpg)
MuseumUses ranging to display information about a piece of art when the associated beacon is in immediate or near proximity.
![Page 31: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/31.jpg)
BEACONinsidegithub.com/beaconinside/BEACONinside-SDK-iOS
Uses the BEACONinside SDK(built on top of Core Location APIs)
![Page 33: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/33.jpg)
Common Problems
![Page 34: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/34.jpg)
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
![Page 35: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/35.jpg)
Ranging
Intermittent signal loss
Signal strength is not a reliable measure for distance
Apps should apply signal smoothing
![Page 36: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/36.jpg)
Creating iBeacons
![Page 37: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/37.jpg)
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];
![Page 38: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/38.jpg)
Core Bluetooth
![Page 39: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/39.jpg)
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
![Page 40: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/40.jpg)
Agenda
Working with iBeacons on iOSExplore iBeacons at Betahaus
Discussion/Q&A
![Page 41: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/41.jpg)
Agenda
Working with iBeacons on iOSExplore iBeacons at Betahaus
Discussion/Q&A
![Page 42: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/42.jpg)
Limitations on iOS
Scanning for beacons with unknown UUIDs is not possible
![Page 43: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/43.jpg)
App Store Policy
Not permitted to expose UUIDs to users
Makes it difficult to write apps that work with the userʼs own beacons
![Page 44: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/44.jpg)
![Page 45: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/45.jpg)
Documentation
![Page 46: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/46.jpg)
developer.apple.com/ibeacon/
![Page 48: iBeacon Development on iOS](https://reader033.vdocuments.mx/reader033/viewer/2022052205/53f8ba368d7f7253318b4829/html5/thumbnails/48.jpg)