34
Stefano Zanetti § DevCamp iBeacons the new low-powered way of location awareness

iBeacons - the new low-powered way of location awareness

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: iBeacons - the new low-powered way of location awareness

Stefano Zanetti sect DevCamp

iBeaconsthe new low-powered way of location awareness

DevCamp

Stefano Zanetti

Apple iOS Developer Superpartes Innovation Campus amp H-Farm13

Co-founder di Pragma Mark ― wwwpragmamarkorg13

[tt] stezanna[in] Stefano Zanetti [fb] stefanoznt [email] stefanozanettipragmamarkorg

DevCamp

What is a Beacon

A Bluetooth LE radio some minor electronic components and a button cell

Thatrsquos all

DevCamp

estimotecom radiusnetworkscom kontaktio

DevCamp

How Beacons could change the world

1 Your home will automatically react to you

2 Your phone will give you a tour of museums

3 Tickets that automatically load as you enter sporting events

4 hellip

DevCamp

Bluetooth LE

DevCamp

a lot of versionshellip

bull first stable version 12 (2003)13

bull 20 + EDR (2004)13

bull 21 + EDR (2007)13

bull 30 + HS (2009)13

bull 40 amp 40 LE (2010)

DevCamp

ISM 24GHz

This is in the globally unlicensed (but not unregulated) Industrial Scientific and Medical

(ISM) 24 GHz short-range radio frequency band

2400ndash24835 MHz

DevCamp

Mbi

ts

0

75

15

225

30

version

v12 v2o+EDR v30+HS v40 v4 LE

03Mbits

24Mbits24Mbits

3Mbits1Mbits

Speed

DevCamp

Other differences

classic bluetooth bluetooth low energy

latency 100ms 6ms

total time to send data 100ms 3ms

peak current consumption lt30mA lt15mA

active slaves 7 implementation dependent

profile standard BT profile like SPP DUN PAN

GATT Generic Attribute profile

paring YES NO

DevCamp

Single and Double mode

Classic and low energy BT are not compatible with each other

Single-mode devices

Classic OR low energy radio

Double-mode devices

Classic AND low energy radio

DevCamp

Connectionless

Devices do not need to maintain a connection for useful information to be exchanged quickly

between them

The connectionless model solves these problems by not defining the state of a connection but the state of the device

DevCamp

Stateless

Any client can send any request at any time and the server will respond to the same

request in exactly the same way regardless of which client made the request

DevCamp

Packet structure

DevCamp

Advertising packet

bull Preamble - 1 Byte - fixed 8bit to synchronize bit timing and set radiorsquos automatic gain control 101010101 or 010101010

bull Access Address - 4 Bytes - 32 fixed and random bit 0x8E89BED6 (that in binary is 01101011011111011001000101110001 The preamble would be 01010101)

bull Header - 1 Byte - to describe the contents of packet

bull Length - 1 Byte - to describe the payload length

bull CRC - 3 Bytes checksum calculated over PDU

bull PDU (Protocol Data Unit) - 37 Bytes

DevCamp

iBeacon

DevCamp

iBeacon is a new technology that extends Location Services in iOS

iBeacons provide a way to create and monitor beacons that advertise certain identifying information using Bluetooth

low energy wireless technology

(ref iOS 7 Understanding Location Services - Apple)

DevCamp

example of iBeacon PDU9F436059ADC00201061AFF4C000215B9407F30F5F8466EAFF925556B57FE6D010000FFB6

9F436059ADC0 Beaconrsquos Bluetooth MAC address02 Length of the next field01 Flags field identifier06 Flags (LE General Discoverable Mode)1A Length of the next fieldFF Manufacturer Specific Data field identifier4C00 Applersquos ID0215 Two fixed bytesB9407F30F5F8466EAFF925556B57FE6D Proximity UUID0100 Major00FF MinorB6 Measured power

DevCamp

iOS Frameworks

iBeacon

Core Bluetooth

Core Location

DevCamp

iOS Classes

CLBeacon

CLLocationManagerCLLocationManagerDelegate

CBPeripheralManager

CBPeripheral

CBCentralManager

CLBeaconRegion

DevCamp

CLBeacon

Identifying the Beacon131313 proximityUUID property13 1313 major property13 1313 minor property13 Determining the Beacon Distance131313 proximity property13 1313 accuracy property13 1313 rssi property13

DevCamp

CLBeaconRegion

Initializing the Beacon Region13 ndash initWithProximityUUIDidentifier13 ndash initWithProximityUUIDmajoridentifier13 ndash initWithProximityUUIDmajorminoridentifier13 Accessing the Beacon Attributes131313 proximityUUID property13 1313 major property13 1313 minor property13 Delivering Beacon Notifications131313 notifyEntryStateOnDisplay property13 Getting Beacon Advertisement Data13 ndash peripheralDataWithMeasuredPower

DevCamp

Code

DevCamp

iDevice as an iBeacon

selfmanager = [[CBPeripheralManager alloc] initWithDelegateself queuenil] NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid major1234 minor12 identifierldquoMy regionrdquo] [selfmanager startAdvertising[region peripheralDataWithMeasuredPowernil]] [selfmanager stopAdvertising]

DevCamp

Monitoring amp Ranging

NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid identifierldquoMy regionrdquo] selfmanager = [[CLLocationManager alloc] init] selfmanagerdelegate = self [selfmanager startMonitoringForRegionregion] [selfmanager requestStateForRegionregion]

DevCamp

- (void)locationManager(CLLocationManager )manager didDetermineState(CLRegionState)state forRegion(CLRegion )region if (state == CLRegionStateInside) NSLog(ldquoINSIDE REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didEnterRegion(CLRegion )region NSLog(ldquoENTER REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didExitRegion(CLRegion )region NSLog(ldquoEXIT REGION) [manager stopRangingBeaconsInRegion(CLBeaconRegion )region]

DevCamp

- (void)locationManager(CLLocationManager )manager didRangeBeacons(NSArray )beacons inRegion(CLBeaconRegion )region for (CLBeacon beacon in beacons) NSLog( zd f beaconmajor beaconminor [Unknown Immediate Near Far][beaconproximity] beaconrssi beaconaccuracy)

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 2: iBeacons - the new low-powered way of location awareness

DevCamp

Stefano Zanetti

Apple iOS Developer Superpartes Innovation Campus amp H-Farm13

Co-founder di Pragma Mark ― wwwpragmamarkorg13

[tt] stezanna[in] Stefano Zanetti [fb] stefanoznt [email] stefanozanettipragmamarkorg

DevCamp

What is a Beacon

A Bluetooth LE radio some minor electronic components and a button cell

Thatrsquos all

DevCamp

estimotecom radiusnetworkscom kontaktio

DevCamp

How Beacons could change the world

1 Your home will automatically react to you

2 Your phone will give you a tour of museums

3 Tickets that automatically load as you enter sporting events

4 hellip

DevCamp

Bluetooth LE

DevCamp

a lot of versionshellip

bull first stable version 12 (2003)13

bull 20 + EDR (2004)13

bull 21 + EDR (2007)13

bull 30 + HS (2009)13

bull 40 amp 40 LE (2010)

DevCamp

ISM 24GHz

This is in the globally unlicensed (but not unregulated) Industrial Scientific and Medical

(ISM) 24 GHz short-range radio frequency band

2400ndash24835 MHz

DevCamp

Mbi

ts

0

75

15

225

30

version

v12 v2o+EDR v30+HS v40 v4 LE

03Mbits

24Mbits24Mbits

3Mbits1Mbits

Speed

DevCamp

Other differences

classic bluetooth bluetooth low energy

latency 100ms 6ms

total time to send data 100ms 3ms

peak current consumption lt30mA lt15mA

active slaves 7 implementation dependent

profile standard BT profile like SPP DUN PAN

GATT Generic Attribute profile

paring YES NO

DevCamp

Single and Double mode

Classic and low energy BT are not compatible with each other

Single-mode devices

Classic OR low energy radio

Double-mode devices

Classic AND low energy radio

DevCamp

Connectionless

Devices do not need to maintain a connection for useful information to be exchanged quickly

between them

The connectionless model solves these problems by not defining the state of a connection but the state of the device

DevCamp

Stateless

Any client can send any request at any time and the server will respond to the same

request in exactly the same way regardless of which client made the request

DevCamp

Packet structure

DevCamp

Advertising packet

bull Preamble - 1 Byte - fixed 8bit to synchronize bit timing and set radiorsquos automatic gain control 101010101 or 010101010

bull Access Address - 4 Bytes - 32 fixed and random bit 0x8E89BED6 (that in binary is 01101011011111011001000101110001 The preamble would be 01010101)

bull Header - 1 Byte - to describe the contents of packet

bull Length - 1 Byte - to describe the payload length

bull CRC - 3 Bytes checksum calculated over PDU

bull PDU (Protocol Data Unit) - 37 Bytes

DevCamp

iBeacon

DevCamp

iBeacon is a new technology that extends Location Services in iOS

iBeacons provide a way to create and monitor beacons that advertise certain identifying information using Bluetooth

low energy wireless technology

(ref iOS 7 Understanding Location Services - Apple)

DevCamp

example of iBeacon PDU9F436059ADC00201061AFF4C000215B9407F30F5F8466EAFF925556B57FE6D010000FFB6

9F436059ADC0 Beaconrsquos Bluetooth MAC address02 Length of the next field01 Flags field identifier06 Flags (LE General Discoverable Mode)1A Length of the next fieldFF Manufacturer Specific Data field identifier4C00 Applersquos ID0215 Two fixed bytesB9407F30F5F8466EAFF925556B57FE6D Proximity UUID0100 Major00FF MinorB6 Measured power

DevCamp

iOS Frameworks

iBeacon

Core Bluetooth

Core Location

DevCamp

iOS Classes

CLBeacon

CLLocationManagerCLLocationManagerDelegate

CBPeripheralManager

CBPeripheral

CBCentralManager

CLBeaconRegion

DevCamp

CLBeacon

Identifying the Beacon131313 proximityUUID property13 1313 major property13 1313 minor property13 Determining the Beacon Distance131313 proximity property13 1313 accuracy property13 1313 rssi property13

DevCamp

CLBeaconRegion

Initializing the Beacon Region13 ndash initWithProximityUUIDidentifier13 ndash initWithProximityUUIDmajoridentifier13 ndash initWithProximityUUIDmajorminoridentifier13 Accessing the Beacon Attributes131313 proximityUUID property13 1313 major property13 1313 minor property13 Delivering Beacon Notifications131313 notifyEntryStateOnDisplay property13 Getting Beacon Advertisement Data13 ndash peripheralDataWithMeasuredPower

DevCamp

Code

DevCamp

iDevice as an iBeacon

selfmanager = [[CBPeripheralManager alloc] initWithDelegateself queuenil] NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid major1234 minor12 identifierldquoMy regionrdquo] [selfmanager startAdvertising[region peripheralDataWithMeasuredPowernil]] [selfmanager stopAdvertising]

DevCamp

Monitoring amp Ranging

NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid identifierldquoMy regionrdquo] selfmanager = [[CLLocationManager alloc] init] selfmanagerdelegate = self [selfmanager startMonitoringForRegionregion] [selfmanager requestStateForRegionregion]

DevCamp

- (void)locationManager(CLLocationManager )manager didDetermineState(CLRegionState)state forRegion(CLRegion )region if (state == CLRegionStateInside) NSLog(ldquoINSIDE REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didEnterRegion(CLRegion )region NSLog(ldquoENTER REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didExitRegion(CLRegion )region NSLog(ldquoEXIT REGION) [manager stopRangingBeaconsInRegion(CLBeaconRegion )region]

DevCamp

- (void)locationManager(CLLocationManager )manager didRangeBeacons(NSArray )beacons inRegion(CLBeaconRegion )region for (CLBeacon beacon in beacons) NSLog( zd f beaconmajor beaconminor [Unknown Immediate Near Far][beaconproximity] beaconrssi beaconaccuracy)

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 3: iBeacons - the new low-powered way of location awareness

DevCamp

What is a Beacon

A Bluetooth LE radio some minor electronic components and a button cell

Thatrsquos all

DevCamp

estimotecom radiusnetworkscom kontaktio

DevCamp

How Beacons could change the world

1 Your home will automatically react to you

2 Your phone will give you a tour of museums

3 Tickets that automatically load as you enter sporting events

4 hellip

DevCamp

Bluetooth LE

DevCamp

a lot of versionshellip

bull first stable version 12 (2003)13

bull 20 + EDR (2004)13

bull 21 + EDR (2007)13

bull 30 + HS (2009)13

bull 40 amp 40 LE (2010)

DevCamp

ISM 24GHz

This is in the globally unlicensed (but not unregulated) Industrial Scientific and Medical

(ISM) 24 GHz short-range radio frequency band

2400ndash24835 MHz

DevCamp

Mbi

ts

0

75

15

225

30

version

v12 v2o+EDR v30+HS v40 v4 LE

03Mbits

24Mbits24Mbits

3Mbits1Mbits

Speed

DevCamp

Other differences

classic bluetooth bluetooth low energy

latency 100ms 6ms

total time to send data 100ms 3ms

peak current consumption lt30mA lt15mA

active slaves 7 implementation dependent

profile standard BT profile like SPP DUN PAN

GATT Generic Attribute profile

paring YES NO

DevCamp

Single and Double mode

Classic and low energy BT are not compatible with each other

Single-mode devices

Classic OR low energy radio

Double-mode devices

Classic AND low energy radio

DevCamp

Connectionless

Devices do not need to maintain a connection for useful information to be exchanged quickly

between them

The connectionless model solves these problems by not defining the state of a connection but the state of the device

DevCamp

Stateless

Any client can send any request at any time and the server will respond to the same

request in exactly the same way regardless of which client made the request

DevCamp

Packet structure

DevCamp

Advertising packet

bull Preamble - 1 Byte - fixed 8bit to synchronize bit timing and set radiorsquos automatic gain control 101010101 or 010101010

bull Access Address - 4 Bytes - 32 fixed and random bit 0x8E89BED6 (that in binary is 01101011011111011001000101110001 The preamble would be 01010101)

bull Header - 1 Byte - to describe the contents of packet

bull Length - 1 Byte - to describe the payload length

bull CRC - 3 Bytes checksum calculated over PDU

bull PDU (Protocol Data Unit) - 37 Bytes

DevCamp

iBeacon

DevCamp

iBeacon is a new technology that extends Location Services in iOS

iBeacons provide a way to create and monitor beacons that advertise certain identifying information using Bluetooth

low energy wireless technology

(ref iOS 7 Understanding Location Services - Apple)

DevCamp

example of iBeacon PDU9F436059ADC00201061AFF4C000215B9407F30F5F8466EAFF925556B57FE6D010000FFB6

9F436059ADC0 Beaconrsquos Bluetooth MAC address02 Length of the next field01 Flags field identifier06 Flags (LE General Discoverable Mode)1A Length of the next fieldFF Manufacturer Specific Data field identifier4C00 Applersquos ID0215 Two fixed bytesB9407F30F5F8466EAFF925556B57FE6D Proximity UUID0100 Major00FF MinorB6 Measured power

DevCamp

iOS Frameworks

iBeacon

Core Bluetooth

Core Location

DevCamp

iOS Classes

CLBeacon

CLLocationManagerCLLocationManagerDelegate

CBPeripheralManager

CBPeripheral

CBCentralManager

CLBeaconRegion

DevCamp

CLBeacon

Identifying the Beacon131313 proximityUUID property13 1313 major property13 1313 minor property13 Determining the Beacon Distance131313 proximity property13 1313 accuracy property13 1313 rssi property13

DevCamp

CLBeaconRegion

Initializing the Beacon Region13 ndash initWithProximityUUIDidentifier13 ndash initWithProximityUUIDmajoridentifier13 ndash initWithProximityUUIDmajorminoridentifier13 Accessing the Beacon Attributes131313 proximityUUID property13 1313 major property13 1313 minor property13 Delivering Beacon Notifications131313 notifyEntryStateOnDisplay property13 Getting Beacon Advertisement Data13 ndash peripheralDataWithMeasuredPower

DevCamp

Code

DevCamp

iDevice as an iBeacon

selfmanager = [[CBPeripheralManager alloc] initWithDelegateself queuenil] NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid major1234 minor12 identifierldquoMy regionrdquo] [selfmanager startAdvertising[region peripheralDataWithMeasuredPowernil]] [selfmanager stopAdvertising]

DevCamp

Monitoring amp Ranging

NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid identifierldquoMy regionrdquo] selfmanager = [[CLLocationManager alloc] init] selfmanagerdelegate = self [selfmanager startMonitoringForRegionregion] [selfmanager requestStateForRegionregion]

DevCamp

- (void)locationManager(CLLocationManager )manager didDetermineState(CLRegionState)state forRegion(CLRegion )region if (state == CLRegionStateInside) NSLog(ldquoINSIDE REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didEnterRegion(CLRegion )region NSLog(ldquoENTER REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didExitRegion(CLRegion )region NSLog(ldquoEXIT REGION) [manager stopRangingBeaconsInRegion(CLBeaconRegion )region]

DevCamp

- (void)locationManager(CLLocationManager )manager didRangeBeacons(NSArray )beacons inRegion(CLBeaconRegion )region for (CLBeacon beacon in beacons) NSLog( zd f beaconmajor beaconminor [Unknown Immediate Near Far][beaconproximity] beaconrssi beaconaccuracy)

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 4: iBeacons - the new low-powered way of location awareness

DevCamp

estimotecom radiusnetworkscom kontaktio

DevCamp

How Beacons could change the world

1 Your home will automatically react to you

2 Your phone will give you a tour of museums

3 Tickets that automatically load as you enter sporting events

4 hellip

DevCamp

Bluetooth LE

DevCamp

a lot of versionshellip

bull first stable version 12 (2003)13

bull 20 + EDR (2004)13

bull 21 + EDR (2007)13

bull 30 + HS (2009)13

bull 40 amp 40 LE (2010)

DevCamp

ISM 24GHz

This is in the globally unlicensed (but not unregulated) Industrial Scientific and Medical

(ISM) 24 GHz short-range radio frequency band

2400ndash24835 MHz

DevCamp

Mbi

ts

0

75

15

225

30

version

v12 v2o+EDR v30+HS v40 v4 LE

03Mbits

24Mbits24Mbits

3Mbits1Mbits

Speed

DevCamp

Other differences

classic bluetooth bluetooth low energy

latency 100ms 6ms

total time to send data 100ms 3ms

peak current consumption lt30mA lt15mA

active slaves 7 implementation dependent

profile standard BT profile like SPP DUN PAN

GATT Generic Attribute profile

paring YES NO

DevCamp

Single and Double mode

Classic and low energy BT are not compatible with each other

Single-mode devices

Classic OR low energy radio

Double-mode devices

Classic AND low energy radio

DevCamp

Connectionless

Devices do not need to maintain a connection for useful information to be exchanged quickly

between them

The connectionless model solves these problems by not defining the state of a connection but the state of the device

DevCamp

Stateless

Any client can send any request at any time and the server will respond to the same

request in exactly the same way regardless of which client made the request

DevCamp

Packet structure

DevCamp

Advertising packet

bull Preamble - 1 Byte - fixed 8bit to synchronize bit timing and set radiorsquos automatic gain control 101010101 or 010101010

bull Access Address - 4 Bytes - 32 fixed and random bit 0x8E89BED6 (that in binary is 01101011011111011001000101110001 The preamble would be 01010101)

bull Header - 1 Byte - to describe the contents of packet

bull Length - 1 Byte - to describe the payload length

bull CRC - 3 Bytes checksum calculated over PDU

bull PDU (Protocol Data Unit) - 37 Bytes

DevCamp

iBeacon

DevCamp

iBeacon is a new technology that extends Location Services in iOS

iBeacons provide a way to create and monitor beacons that advertise certain identifying information using Bluetooth

low energy wireless technology

(ref iOS 7 Understanding Location Services - Apple)

DevCamp

example of iBeacon PDU9F436059ADC00201061AFF4C000215B9407F30F5F8466EAFF925556B57FE6D010000FFB6

9F436059ADC0 Beaconrsquos Bluetooth MAC address02 Length of the next field01 Flags field identifier06 Flags (LE General Discoverable Mode)1A Length of the next fieldFF Manufacturer Specific Data field identifier4C00 Applersquos ID0215 Two fixed bytesB9407F30F5F8466EAFF925556B57FE6D Proximity UUID0100 Major00FF MinorB6 Measured power

DevCamp

iOS Frameworks

iBeacon

Core Bluetooth

Core Location

DevCamp

iOS Classes

CLBeacon

CLLocationManagerCLLocationManagerDelegate

CBPeripheralManager

CBPeripheral

CBCentralManager

CLBeaconRegion

DevCamp

CLBeacon

Identifying the Beacon131313 proximityUUID property13 1313 major property13 1313 minor property13 Determining the Beacon Distance131313 proximity property13 1313 accuracy property13 1313 rssi property13

DevCamp

CLBeaconRegion

Initializing the Beacon Region13 ndash initWithProximityUUIDidentifier13 ndash initWithProximityUUIDmajoridentifier13 ndash initWithProximityUUIDmajorminoridentifier13 Accessing the Beacon Attributes131313 proximityUUID property13 1313 major property13 1313 minor property13 Delivering Beacon Notifications131313 notifyEntryStateOnDisplay property13 Getting Beacon Advertisement Data13 ndash peripheralDataWithMeasuredPower

DevCamp

Code

DevCamp

iDevice as an iBeacon

selfmanager = [[CBPeripheralManager alloc] initWithDelegateself queuenil] NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid major1234 minor12 identifierldquoMy regionrdquo] [selfmanager startAdvertising[region peripheralDataWithMeasuredPowernil]] [selfmanager stopAdvertising]

DevCamp

Monitoring amp Ranging

NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid identifierldquoMy regionrdquo] selfmanager = [[CLLocationManager alloc] init] selfmanagerdelegate = self [selfmanager startMonitoringForRegionregion] [selfmanager requestStateForRegionregion]

DevCamp

- (void)locationManager(CLLocationManager )manager didDetermineState(CLRegionState)state forRegion(CLRegion )region if (state == CLRegionStateInside) NSLog(ldquoINSIDE REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didEnterRegion(CLRegion )region NSLog(ldquoENTER REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didExitRegion(CLRegion )region NSLog(ldquoEXIT REGION) [manager stopRangingBeaconsInRegion(CLBeaconRegion )region]

DevCamp

- (void)locationManager(CLLocationManager )manager didRangeBeacons(NSArray )beacons inRegion(CLBeaconRegion )region for (CLBeacon beacon in beacons) NSLog( zd f beaconmajor beaconminor [Unknown Immediate Near Far][beaconproximity] beaconrssi beaconaccuracy)

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 5: iBeacons - the new low-powered way of location awareness

DevCamp

How Beacons could change the world

1 Your home will automatically react to you

2 Your phone will give you a tour of museums

3 Tickets that automatically load as you enter sporting events

4 hellip

DevCamp

Bluetooth LE

DevCamp

a lot of versionshellip

bull first stable version 12 (2003)13

bull 20 + EDR (2004)13

bull 21 + EDR (2007)13

bull 30 + HS (2009)13

bull 40 amp 40 LE (2010)

DevCamp

ISM 24GHz

This is in the globally unlicensed (but not unregulated) Industrial Scientific and Medical

(ISM) 24 GHz short-range radio frequency band

2400ndash24835 MHz

DevCamp

Mbi

ts

0

75

15

225

30

version

v12 v2o+EDR v30+HS v40 v4 LE

03Mbits

24Mbits24Mbits

3Mbits1Mbits

Speed

DevCamp

Other differences

classic bluetooth bluetooth low energy

latency 100ms 6ms

total time to send data 100ms 3ms

peak current consumption lt30mA lt15mA

active slaves 7 implementation dependent

profile standard BT profile like SPP DUN PAN

GATT Generic Attribute profile

paring YES NO

DevCamp

Single and Double mode

Classic and low energy BT are not compatible with each other

Single-mode devices

Classic OR low energy radio

Double-mode devices

Classic AND low energy radio

DevCamp

Connectionless

Devices do not need to maintain a connection for useful information to be exchanged quickly

between them

The connectionless model solves these problems by not defining the state of a connection but the state of the device

DevCamp

Stateless

Any client can send any request at any time and the server will respond to the same

request in exactly the same way regardless of which client made the request

DevCamp

Packet structure

DevCamp

Advertising packet

bull Preamble - 1 Byte - fixed 8bit to synchronize bit timing and set radiorsquos automatic gain control 101010101 or 010101010

bull Access Address - 4 Bytes - 32 fixed and random bit 0x8E89BED6 (that in binary is 01101011011111011001000101110001 The preamble would be 01010101)

bull Header - 1 Byte - to describe the contents of packet

bull Length - 1 Byte - to describe the payload length

bull CRC - 3 Bytes checksum calculated over PDU

bull PDU (Protocol Data Unit) - 37 Bytes

DevCamp

iBeacon

DevCamp

iBeacon is a new technology that extends Location Services in iOS

iBeacons provide a way to create and monitor beacons that advertise certain identifying information using Bluetooth

low energy wireless technology

(ref iOS 7 Understanding Location Services - Apple)

DevCamp

example of iBeacon PDU9F436059ADC00201061AFF4C000215B9407F30F5F8466EAFF925556B57FE6D010000FFB6

9F436059ADC0 Beaconrsquos Bluetooth MAC address02 Length of the next field01 Flags field identifier06 Flags (LE General Discoverable Mode)1A Length of the next fieldFF Manufacturer Specific Data field identifier4C00 Applersquos ID0215 Two fixed bytesB9407F30F5F8466EAFF925556B57FE6D Proximity UUID0100 Major00FF MinorB6 Measured power

DevCamp

iOS Frameworks

iBeacon

Core Bluetooth

Core Location

DevCamp

iOS Classes

CLBeacon

CLLocationManagerCLLocationManagerDelegate

CBPeripheralManager

CBPeripheral

CBCentralManager

CLBeaconRegion

DevCamp

CLBeacon

Identifying the Beacon131313 proximityUUID property13 1313 major property13 1313 minor property13 Determining the Beacon Distance131313 proximity property13 1313 accuracy property13 1313 rssi property13

DevCamp

CLBeaconRegion

Initializing the Beacon Region13 ndash initWithProximityUUIDidentifier13 ndash initWithProximityUUIDmajoridentifier13 ndash initWithProximityUUIDmajorminoridentifier13 Accessing the Beacon Attributes131313 proximityUUID property13 1313 major property13 1313 minor property13 Delivering Beacon Notifications131313 notifyEntryStateOnDisplay property13 Getting Beacon Advertisement Data13 ndash peripheralDataWithMeasuredPower

DevCamp

Code

DevCamp

iDevice as an iBeacon

selfmanager = [[CBPeripheralManager alloc] initWithDelegateself queuenil] NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid major1234 minor12 identifierldquoMy regionrdquo] [selfmanager startAdvertising[region peripheralDataWithMeasuredPowernil]] [selfmanager stopAdvertising]

DevCamp

Monitoring amp Ranging

NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid identifierldquoMy regionrdquo] selfmanager = [[CLLocationManager alloc] init] selfmanagerdelegate = self [selfmanager startMonitoringForRegionregion] [selfmanager requestStateForRegionregion]

DevCamp

- (void)locationManager(CLLocationManager )manager didDetermineState(CLRegionState)state forRegion(CLRegion )region if (state == CLRegionStateInside) NSLog(ldquoINSIDE REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didEnterRegion(CLRegion )region NSLog(ldquoENTER REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didExitRegion(CLRegion )region NSLog(ldquoEXIT REGION) [manager stopRangingBeaconsInRegion(CLBeaconRegion )region]

DevCamp

- (void)locationManager(CLLocationManager )manager didRangeBeacons(NSArray )beacons inRegion(CLBeaconRegion )region for (CLBeacon beacon in beacons) NSLog( zd f beaconmajor beaconminor [Unknown Immediate Near Far][beaconproximity] beaconrssi beaconaccuracy)

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 6: iBeacons - the new low-powered way of location awareness

DevCamp

Bluetooth LE

DevCamp

a lot of versionshellip

bull first stable version 12 (2003)13

bull 20 + EDR (2004)13

bull 21 + EDR (2007)13

bull 30 + HS (2009)13

bull 40 amp 40 LE (2010)

DevCamp

ISM 24GHz

This is in the globally unlicensed (but not unregulated) Industrial Scientific and Medical

(ISM) 24 GHz short-range radio frequency band

2400ndash24835 MHz

DevCamp

Mbi

ts

0

75

15

225

30

version

v12 v2o+EDR v30+HS v40 v4 LE

03Mbits

24Mbits24Mbits

3Mbits1Mbits

Speed

DevCamp

Other differences

classic bluetooth bluetooth low energy

latency 100ms 6ms

total time to send data 100ms 3ms

peak current consumption lt30mA lt15mA

active slaves 7 implementation dependent

profile standard BT profile like SPP DUN PAN

GATT Generic Attribute profile

paring YES NO

DevCamp

Single and Double mode

Classic and low energy BT are not compatible with each other

Single-mode devices

Classic OR low energy radio

Double-mode devices

Classic AND low energy radio

DevCamp

Connectionless

Devices do not need to maintain a connection for useful information to be exchanged quickly

between them

The connectionless model solves these problems by not defining the state of a connection but the state of the device

DevCamp

Stateless

Any client can send any request at any time and the server will respond to the same

request in exactly the same way regardless of which client made the request

DevCamp

Packet structure

DevCamp

Advertising packet

bull Preamble - 1 Byte - fixed 8bit to synchronize bit timing and set radiorsquos automatic gain control 101010101 or 010101010

bull Access Address - 4 Bytes - 32 fixed and random bit 0x8E89BED6 (that in binary is 01101011011111011001000101110001 The preamble would be 01010101)

bull Header - 1 Byte - to describe the contents of packet

bull Length - 1 Byte - to describe the payload length

bull CRC - 3 Bytes checksum calculated over PDU

bull PDU (Protocol Data Unit) - 37 Bytes

DevCamp

iBeacon

DevCamp

iBeacon is a new technology that extends Location Services in iOS

iBeacons provide a way to create and monitor beacons that advertise certain identifying information using Bluetooth

low energy wireless technology

(ref iOS 7 Understanding Location Services - Apple)

DevCamp

example of iBeacon PDU9F436059ADC00201061AFF4C000215B9407F30F5F8466EAFF925556B57FE6D010000FFB6

9F436059ADC0 Beaconrsquos Bluetooth MAC address02 Length of the next field01 Flags field identifier06 Flags (LE General Discoverable Mode)1A Length of the next fieldFF Manufacturer Specific Data field identifier4C00 Applersquos ID0215 Two fixed bytesB9407F30F5F8466EAFF925556B57FE6D Proximity UUID0100 Major00FF MinorB6 Measured power

DevCamp

iOS Frameworks

iBeacon

Core Bluetooth

Core Location

DevCamp

iOS Classes

CLBeacon

CLLocationManagerCLLocationManagerDelegate

CBPeripheralManager

CBPeripheral

CBCentralManager

CLBeaconRegion

DevCamp

CLBeacon

Identifying the Beacon131313 proximityUUID property13 1313 major property13 1313 minor property13 Determining the Beacon Distance131313 proximity property13 1313 accuracy property13 1313 rssi property13

DevCamp

CLBeaconRegion

Initializing the Beacon Region13 ndash initWithProximityUUIDidentifier13 ndash initWithProximityUUIDmajoridentifier13 ndash initWithProximityUUIDmajorminoridentifier13 Accessing the Beacon Attributes131313 proximityUUID property13 1313 major property13 1313 minor property13 Delivering Beacon Notifications131313 notifyEntryStateOnDisplay property13 Getting Beacon Advertisement Data13 ndash peripheralDataWithMeasuredPower

DevCamp

Code

DevCamp

iDevice as an iBeacon

selfmanager = [[CBPeripheralManager alloc] initWithDelegateself queuenil] NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid major1234 minor12 identifierldquoMy regionrdquo] [selfmanager startAdvertising[region peripheralDataWithMeasuredPowernil]] [selfmanager stopAdvertising]

DevCamp

Monitoring amp Ranging

NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid identifierldquoMy regionrdquo] selfmanager = [[CLLocationManager alloc] init] selfmanagerdelegate = self [selfmanager startMonitoringForRegionregion] [selfmanager requestStateForRegionregion]

DevCamp

- (void)locationManager(CLLocationManager )manager didDetermineState(CLRegionState)state forRegion(CLRegion )region if (state == CLRegionStateInside) NSLog(ldquoINSIDE REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didEnterRegion(CLRegion )region NSLog(ldquoENTER REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didExitRegion(CLRegion )region NSLog(ldquoEXIT REGION) [manager stopRangingBeaconsInRegion(CLBeaconRegion )region]

DevCamp

- (void)locationManager(CLLocationManager )manager didRangeBeacons(NSArray )beacons inRegion(CLBeaconRegion )region for (CLBeacon beacon in beacons) NSLog( zd f beaconmajor beaconminor [Unknown Immediate Near Far][beaconproximity] beaconrssi beaconaccuracy)

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 7: iBeacons - the new low-powered way of location awareness

DevCamp

a lot of versionshellip

bull first stable version 12 (2003)13

bull 20 + EDR (2004)13

bull 21 + EDR (2007)13

bull 30 + HS (2009)13

bull 40 amp 40 LE (2010)

DevCamp

ISM 24GHz

This is in the globally unlicensed (but not unregulated) Industrial Scientific and Medical

(ISM) 24 GHz short-range radio frequency band

2400ndash24835 MHz

DevCamp

Mbi

ts

0

75

15

225

30

version

v12 v2o+EDR v30+HS v40 v4 LE

03Mbits

24Mbits24Mbits

3Mbits1Mbits

Speed

DevCamp

Other differences

classic bluetooth bluetooth low energy

latency 100ms 6ms

total time to send data 100ms 3ms

peak current consumption lt30mA lt15mA

active slaves 7 implementation dependent

profile standard BT profile like SPP DUN PAN

GATT Generic Attribute profile

paring YES NO

DevCamp

Single and Double mode

Classic and low energy BT are not compatible with each other

Single-mode devices

Classic OR low energy radio

Double-mode devices

Classic AND low energy radio

DevCamp

Connectionless

Devices do not need to maintain a connection for useful information to be exchanged quickly

between them

The connectionless model solves these problems by not defining the state of a connection but the state of the device

DevCamp

Stateless

Any client can send any request at any time and the server will respond to the same

request in exactly the same way regardless of which client made the request

DevCamp

Packet structure

DevCamp

Advertising packet

bull Preamble - 1 Byte - fixed 8bit to synchronize bit timing and set radiorsquos automatic gain control 101010101 or 010101010

bull Access Address - 4 Bytes - 32 fixed and random bit 0x8E89BED6 (that in binary is 01101011011111011001000101110001 The preamble would be 01010101)

bull Header - 1 Byte - to describe the contents of packet

bull Length - 1 Byte - to describe the payload length

bull CRC - 3 Bytes checksum calculated over PDU

bull PDU (Protocol Data Unit) - 37 Bytes

DevCamp

iBeacon

DevCamp

iBeacon is a new technology that extends Location Services in iOS

iBeacons provide a way to create and monitor beacons that advertise certain identifying information using Bluetooth

low energy wireless technology

(ref iOS 7 Understanding Location Services - Apple)

DevCamp

example of iBeacon PDU9F436059ADC00201061AFF4C000215B9407F30F5F8466EAFF925556B57FE6D010000FFB6

9F436059ADC0 Beaconrsquos Bluetooth MAC address02 Length of the next field01 Flags field identifier06 Flags (LE General Discoverable Mode)1A Length of the next fieldFF Manufacturer Specific Data field identifier4C00 Applersquos ID0215 Two fixed bytesB9407F30F5F8466EAFF925556B57FE6D Proximity UUID0100 Major00FF MinorB6 Measured power

DevCamp

iOS Frameworks

iBeacon

Core Bluetooth

Core Location

DevCamp

iOS Classes

CLBeacon

CLLocationManagerCLLocationManagerDelegate

CBPeripheralManager

CBPeripheral

CBCentralManager

CLBeaconRegion

DevCamp

CLBeacon

Identifying the Beacon131313 proximityUUID property13 1313 major property13 1313 minor property13 Determining the Beacon Distance131313 proximity property13 1313 accuracy property13 1313 rssi property13

DevCamp

CLBeaconRegion

Initializing the Beacon Region13 ndash initWithProximityUUIDidentifier13 ndash initWithProximityUUIDmajoridentifier13 ndash initWithProximityUUIDmajorminoridentifier13 Accessing the Beacon Attributes131313 proximityUUID property13 1313 major property13 1313 minor property13 Delivering Beacon Notifications131313 notifyEntryStateOnDisplay property13 Getting Beacon Advertisement Data13 ndash peripheralDataWithMeasuredPower

DevCamp

Code

DevCamp

iDevice as an iBeacon

selfmanager = [[CBPeripheralManager alloc] initWithDelegateself queuenil] NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid major1234 minor12 identifierldquoMy regionrdquo] [selfmanager startAdvertising[region peripheralDataWithMeasuredPowernil]] [selfmanager stopAdvertising]

DevCamp

Monitoring amp Ranging

NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid identifierldquoMy regionrdquo] selfmanager = [[CLLocationManager alloc] init] selfmanagerdelegate = self [selfmanager startMonitoringForRegionregion] [selfmanager requestStateForRegionregion]

DevCamp

- (void)locationManager(CLLocationManager )manager didDetermineState(CLRegionState)state forRegion(CLRegion )region if (state == CLRegionStateInside) NSLog(ldquoINSIDE REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didEnterRegion(CLRegion )region NSLog(ldquoENTER REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didExitRegion(CLRegion )region NSLog(ldquoEXIT REGION) [manager stopRangingBeaconsInRegion(CLBeaconRegion )region]

DevCamp

- (void)locationManager(CLLocationManager )manager didRangeBeacons(NSArray )beacons inRegion(CLBeaconRegion )region for (CLBeacon beacon in beacons) NSLog( zd f beaconmajor beaconminor [Unknown Immediate Near Far][beaconproximity] beaconrssi beaconaccuracy)

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 8: iBeacons - the new low-powered way of location awareness

DevCamp

ISM 24GHz

This is in the globally unlicensed (but not unregulated) Industrial Scientific and Medical

(ISM) 24 GHz short-range radio frequency band

2400ndash24835 MHz

DevCamp

Mbi

ts

0

75

15

225

30

version

v12 v2o+EDR v30+HS v40 v4 LE

03Mbits

24Mbits24Mbits

3Mbits1Mbits

Speed

DevCamp

Other differences

classic bluetooth bluetooth low energy

latency 100ms 6ms

total time to send data 100ms 3ms

peak current consumption lt30mA lt15mA

active slaves 7 implementation dependent

profile standard BT profile like SPP DUN PAN

GATT Generic Attribute profile

paring YES NO

DevCamp

Single and Double mode

Classic and low energy BT are not compatible with each other

Single-mode devices

Classic OR low energy radio

Double-mode devices

Classic AND low energy radio

DevCamp

Connectionless

Devices do not need to maintain a connection for useful information to be exchanged quickly

between them

The connectionless model solves these problems by not defining the state of a connection but the state of the device

DevCamp

Stateless

Any client can send any request at any time and the server will respond to the same

request in exactly the same way regardless of which client made the request

DevCamp

Packet structure

DevCamp

Advertising packet

bull Preamble - 1 Byte - fixed 8bit to synchronize bit timing and set radiorsquos automatic gain control 101010101 or 010101010

bull Access Address - 4 Bytes - 32 fixed and random bit 0x8E89BED6 (that in binary is 01101011011111011001000101110001 The preamble would be 01010101)

bull Header - 1 Byte - to describe the contents of packet

bull Length - 1 Byte - to describe the payload length

bull CRC - 3 Bytes checksum calculated over PDU

bull PDU (Protocol Data Unit) - 37 Bytes

DevCamp

iBeacon

DevCamp

iBeacon is a new technology that extends Location Services in iOS

iBeacons provide a way to create and monitor beacons that advertise certain identifying information using Bluetooth

low energy wireless technology

(ref iOS 7 Understanding Location Services - Apple)

DevCamp

example of iBeacon PDU9F436059ADC00201061AFF4C000215B9407F30F5F8466EAFF925556B57FE6D010000FFB6

9F436059ADC0 Beaconrsquos Bluetooth MAC address02 Length of the next field01 Flags field identifier06 Flags (LE General Discoverable Mode)1A Length of the next fieldFF Manufacturer Specific Data field identifier4C00 Applersquos ID0215 Two fixed bytesB9407F30F5F8466EAFF925556B57FE6D Proximity UUID0100 Major00FF MinorB6 Measured power

DevCamp

iOS Frameworks

iBeacon

Core Bluetooth

Core Location

DevCamp

iOS Classes

CLBeacon

CLLocationManagerCLLocationManagerDelegate

CBPeripheralManager

CBPeripheral

CBCentralManager

CLBeaconRegion

DevCamp

CLBeacon

Identifying the Beacon131313 proximityUUID property13 1313 major property13 1313 minor property13 Determining the Beacon Distance131313 proximity property13 1313 accuracy property13 1313 rssi property13

DevCamp

CLBeaconRegion

Initializing the Beacon Region13 ndash initWithProximityUUIDidentifier13 ndash initWithProximityUUIDmajoridentifier13 ndash initWithProximityUUIDmajorminoridentifier13 Accessing the Beacon Attributes131313 proximityUUID property13 1313 major property13 1313 minor property13 Delivering Beacon Notifications131313 notifyEntryStateOnDisplay property13 Getting Beacon Advertisement Data13 ndash peripheralDataWithMeasuredPower

DevCamp

Code

DevCamp

iDevice as an iBeacon

selfmanager = [[CBPeripheralManager alloc] initWithDelegateself queuenil] NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid major1234 minor12 identifierldquoMy regionrdquo] [selfmanager startAdvertising[region peripheralDataWithMeasuredPowernil]] [selfmanager stopAdvertising]

DevCamp

Monitoring amp Ranging

NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid identifierldquoMy regionrdquo] selfmanager = [[CLLocationManager alloc] init] selfmanagerdelegate = self [selfmanager startMonitoringForRegionregion] [selfmanager requestStateForRegionregion]

DevCamp

- (void)locationManager(CLLocationManager )manager didDetermineState(CLRegionState)state forRegion(CLRegion )region if (state == CLRegionStateInside) NSLog(ldquoINSIDE REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didEnterRegion(CLRegion )region NSLog(ldquoENTER REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didExitRegion(CLRegion )region NSLog(ldquoEXIT REGION) [manager stopRangingBeaconsInRegion(CLBeaconRegion )region]

DevCamp

- (void)locationManager(CLLocationManager )manager didRangeBeacons(NSArray )beacons inRegion(CLBeaconRegion )region for (CLBeacon beacon in beacons) NSLog( zd f beaconmajor beaconminor [Unknown Immediate Near Far][beaconproximity] beaconrssi beaconaccuracy)

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 9: iBeacons - the new low-powered way of location awareness

DevCamp

Mbi

ts

0

75

15

225

30

version

v12 v2o+EDR v30+HS v40 v4 LE

03Mbits

24Mbits24Mbits

3Mbits1Mbits

Speed

DevCamp

Other differences

classic bluetooth bluetooth low energy

latency 100ms 6ms

total time to send data 100ms 3ms

peak current consumption lt30mA lt15mA

active slaves 7 implementation dependent

profile standard BT profile like SPP DUN PAN

GATT Generic Attribute profile

paring YES NO

DevCamp

Single and Double mode

Classic and low energy BT are not compatible with each other

Single-mode devices

Classic OR low energy radio

Double-mode devices

Classic AND low energy radio

DevCamp

Connectionless

Devices do not need to maintain a connection for useful information to be exchanged quickly

between them

The connectionless model solves these problems by not defining the state of a connection but the state of the device

DevCamp

Stateless

Any client can send any request at any time and the server will respond to the same

request in exactly the same way regardless of which client made the request

DevCamp

Packet structure

DevCamp

Advertising packet

bull Preamble - 1 Byte - fixed 8bit to synchronize bit timing and set radiorsquos automatic gain control 101010101 or 010101010

bull Access Address - 4 Bytes - 32 fixed and random bit 0x8E89BED6 (that in binary is 01101011011111011001000101110001 The preamble would be 01010101)

bull Header - 1 Byte - to describe the contents of packet

bull Length - 1 Byte - to describe the payload length

bull CRC - 3 Bytes checksum calculated over PDU

bull PDU (Protocol Data Unit) - 37 Bytes

DevCamp

iBeacon

DevCamp

iBeacon is a new technology that extends Location Services in iOS

iBeacons provide a way to create and monitor beacons that advertise certain identifying information using Bluetooth

low energy wireless technology

(ref iOS 7 Understanding Location Services - Apple)

DevCamp

example of iBeacon PDU9F436059ADC00201061AFF4C000215B9407F30F5F8466EAFF925556B57FE6D010000FFB6

9F436059ADC0 Beaconrsquos Bluetooth MAC address02 Length of the next field01 Flags field identifier06 Flags (LE General Discoverable Mode)1A Length of the next fieldFF Manufacturer Specific Data field identifier4C00 Applersquos ID0215 Two fixed bytesB9407F30F5F8466EAFF925556B57FE6D Proximity UUID0100 Major00FF MinorB6 Measured power

DevCamp

iOS Frameworks

iBeacon

Core Bluetooth

Core Location

DevCamp

iOS Classes

CLBeacon

CLLocationManagerCLLocationManagerDelegate

CBPeripheralManager

CBPeripheral

CBCentralManager

CLBeaconRegion

DevCamp

CLBeacon

Identifying the Beacon131313 proximityUUID property13 1313 major property13 1313 minor property13 Determining the Beacon Distance131313 proximity property13 1313 accuracy property13 1313 rssi property13

DevCamp

CLBeaconRegion

Initializing the Beacon Region13 ndash initWithProximityUUIDidentifier13 ndash initWithProximityUUIDmajoridentifier13 ndash initWithProximityUUIDmajorminoridentifier13 Accessing the Beacon Attributes131313 proximityUUID property13 1313 major property13 1313 minor property13 Delivering Beacon Notifications131313 notifyEntryStateOnDisplay property13 Getting Beacon Advertisement Data13 ndash peripheralDataWithMeasuredPower

DevCamp

Code

DevCamp

iDevice as an iBeacon

selfmanager = [[CBPeripheralManager alloc] initWithDelegateself queuenil] NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid major1234 minor12 identifierldquoMy regionrdquo] [selfmanager startAdvertising[region peripheralDataWithMeasuredPowernil]] [selfmanager stopAdvertising]

DevCamp

Monitoring amp Ranging

NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid identifierldquoMy regionrdquo] selfmanager = [[CLLocationManager alloc] init] selfmanagerdelegate = self [selfmanager startMonitoringForRegionregion] [selfmanager requestStateForRegionregion]

DevCamp

- (void)locationManager(CLLocationManager )manager didDetermineState(CLRegionState)state forRegion(CLRegion )region if (state == CLRegionStateInside) NSLog(ldquoINSIDE REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didEnterRegion(CLRegion )region NSLog(ldquoENTER REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didExitRegion(CLRegion )region NSLog(ldquoEXIT REGION) [manager stopRangingBeaconsInRegion(CLBeaconRegion )region]

DevCamp

- (void)locationManager(CLLocationManager )manager didRangeBeacons(NSArray )beacons inRegion(CLBeaconRegion )region for (CLBeacon beacon in beacons) NSLog( zd f beaconmajor beaconminor [Unknown Immediate Near Far][beaconproximity] beaconrssi beaconaccuracy)

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 10: iBeacons - the new low-powered way of location awareness

DevCamp

Other differences

classic bluetooth bluetooth low energy

latency 100ms 6ms

total time to send data 100ms 3ms

peak current consumption lt30mA lt15mA

active slaves 7 implementation dependent

profile standard BT profile like SPP DUN PAN

GATT Generic Attribute profile

paring YES NO

DevCamp

Single and Double mode

Classic and low energy BT are not compatible with each other

Single-mode devices

Classic OR low energy radio

Double-mode devices

Classic AND low energy radio

DevCamp

Connectionless

Devices do not need to maintain a connection for useful information to be exchanged quickly

between them

The connectionless model solves these problems by not defining the state of a connection but the state of the device

DevCamp

Stateless

Any client can send any request at any time and the server will respond to the same

request in exactly the same way regardless of which client made the request

DevCamp

Packet structure

DevCamp

Advertising packet

bull Preamble - 1 Byte - fixed 8bit to synchronize bit timing and set radiorsquos automatic gain control 101010101 or 010101010

bull Access Address - 4 Bytes - 32 fixed and random bit 0x8E89BED6 (that in binary is 01101011011111011001000101110001 The preamble would be 01010101)

bull Header - 1 Byte - to describe the contents of packet

bull Length - 1 Byte - to describe the payload length

bull CRC - 3 Bytes checksum calculated over PDU

bull PDU (Protocol Data Unit) - 37 Bytes

DevCamp

iBeacon

DevCamp

iBeacon is a new technology that extends Location Services in iOS

iBeacons provide a way to create and monitor beacons that advertise certain identifying information using Bluetooth

low energy wireless technology

(ref iOS 7 Understanding Location Services - Apple)

DevCamp

example of iBeacon PDU9F436059ADC00201061AFF4C000215B9407F30F5F8466EAFF925556B57FE6D010000FFB6

9F436059ADC0 Beaconrsquos Bluetooth MAC address02 Length of the next field01 Flags field identifier06 Flags (LE General Discoverable Mode)1A Length of the next fieldFF Manufacturer Specific Data field identifier4C00 Applersquos ID0215 Two fixed bytesB9407F30F5F8466EAFF925556B57FE6D Proximity UUID0100 Major00FF MinorB6 Measured power

DevCamp

iOS Frameworks

iBeacon

Core Bluetooth

Core Location

DevCamp

iOS Classes

CLBeacon

CLLocationManagerCLLocationManagerDelegate

CBPeripheralManager

CBPeripheral

CBCentralManager

CLBeaconRegion

DevCamp

CLBeacon

Identifying the Beacon131313 proximityUUID property13 1313 major property13 1313 minor property13 Determining the Beacon Distance131313 proximity property13 1313 accuracy property13 1313 rssi property13

DevCamp

CLBeaconRegion

Initializing the Beacon Region13 ndash initWithProximityUUIDidentifier13 ndash initWithProximityUUIDmajoridentifier13 ndash initWithProximityUUIDmajorminoridentifier13 Accessing the Beacon Attributes131313 proximityUUID property13 1313 major property13 1313 minor property13 Delivering Beacon Notifications131313 notifyEntryStateOnDisplay property13 Getting Beacon Advertisement Data13 ndash peripheralDataWithMeasuredPower

DevCamp

Code

DevCamp

iDevice as an iBeacon

selfmanager = [[CBPeripheralManager alloc] initWithDelegateself queuenil] NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid major1234 minor12 identifierldquoMy regionrdquo] [selfmanager startAdvertising[region peripheralDataWithMeasuredPowernil]] [selfmanager stopAdvertising]

DevCamp

Monitoring amp Ranging

NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid identifierldquoMy regionrdquo] selfmanager = [[CLLocationManager alloc] init] selfmanagerdelegate = self [selfmanager startMonitoringForRegionregion] [selfmanager requestStateForRegionregion]

DevCamp

- (void)locationManager(CLLocationManager )manager didDetermineState(CLRegionState)state forRegion(CLRegion )region if (state == CLRegionStateInside) NSLog(ldquoINSIDE REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didEnterRegion(CLRegion )region NSLog(ldquoENTER REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didExitRegion(CLRegion )region NSLog(ldquoEXIT REGION) [manager stopRangingBeaconsInRegion(CLBeaconRegion )region]

DevCamp

- (void)locationManager(CLLocationManager )manager didRangeBeacons(NSArray )beacons inRegion(CLBeaconRegion )region for (CLBeacon beacon in beacons) NSLog( zd f beaconmajor beaconminor [Unknown Immediate Near Far][beaconproximity] beaconrssi beaconaccuracy)

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 11: iBeacons - the new low-powered way of location awareness

DevCamp

Single and Double mode

Classic and low energy BT are not compatible with each other

Single-mode devices

Classic OR low energy radio

Double-mode devices

Classic AND low energy radio

DevCamp

Connectionless

Devices do not need to maintain a connection for useful information to be exchanged quickly

between them

The connectionless model solves these problems by not defining the state of a connection but the state of the device

DevCamp

Stateless

Any client can send any request at any time and the server will respond to the same

request in exactly the same way regardless of which client made the request

DevCamp

Packet structure

DevCamp

Advertising packet

bull Preamble - 1 Byte - fixed 8bit to synchronize bit timing and set radiorsquos automatic gain control 101010101 or 010101010

bull Access Address - 4 Bytes - 32 fixed and random bit 0x8E89BED6 (that in binary is 01101011011111011001000101110001 The preamble would be 01010101)

bull Header - 1 Byte - to describe the contents of packet

bull Length - 1 Byte - to describe the payload length

bull CRC - 3 Bytes checksum calculated over PDU

bull PDU (Protocol Data Unit) - 37 Bytes

DevCamp

iBeacon

DevCamp

iBeacon is a new technology that extends Location Services in iOS

iBeacons provide a way to create and monitor beacons that advertise certain identifying information using Bluetooth

low energy wireless technology

(ref iOS 7 Understanding Location Services - Apple)

DevCamp

example of iBeacon PDU9F436059ADC00201061AFF4C000215B9407F30F5F8466EAFF925556B57FE6D010000FFB6

9F436059ADC0 Beaconrsquos Bluetooth MAC address02 Length of the next field01 Flags field identifier06 Flags (LE General Discoverable Mode)1A Length of the next fieldFF Manufacturer Specific Data field identifier4C00 Applersquos ID0215 Two fixed bytesB9407F30F5F8466EAFF925556B57FE6D Proximity UUID0100 Major00FF MinorB6 Measured power

DevCamp

iOS Frameworks

iBeacon

Core Bluetooth

Core Location

DevCamp

iOS Classes

CLBeacon

CLLocationManagerCLLocationManagerDelegate

CBPeripheralManager

CBPeripheral

CBCentralManager

CLBeaconRegion

DevCamp

CLBeacon

Identifying the Beacon131313 proximityUUID property13 1313 major property13 1313 minor property13 Determining the Beacon Distance131313 proximity property13 1313 accuracy property13 1313 rssi property13

DevCamp

CLBeaconRegion

Initializing the Beacon Region13 ndash initWithProximityUUIDidentifier13 ndash initWithProximityUUIDmajoridentifier13 ndash initWithProximityUUIDmajorminoridentifier13 Accessing the Beacon Attributes131313 proximityUUID property13 1313 major property13 1313 minor property13 Delivering Beacon Notifications131313 notifyEntryStateOnDisplay property13 Getting Beacon Advertisement Data13 ndash peripheralDataWithMeasuredPower

DevCamp

Code

DevCamp

iDevice as an iBeacon

selfmanager = [[CBPeripheralManager alloc] initWithDelegateself queuenil] NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid major1234 minor12 identifierldquoMy regionrdquo] [selfmanager startAdvertising[region peripheralDataWithMeasuredPowernil]] [selfmanager stopAdvertising]

DevCamp

Monitoring amp Ranging

NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid identifierldquoMy regionrdquo] selfmanager = [[CLLocationManager alloc] init] selfmanagerdelegate = self [selfmanager startMonitoringForRegionregion] [selfmanager requestStateForRegionregion]

DevCamp

- (void)locationManager(CLLocationManager )manager didDetermineState(CLRegionState)state forRegion(CLRegion )region if (state == CLRegionStateInside) NSLog(ldquoINSIDE REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didEnterRegion(CLRegion )region NSLog(ldquoENTER REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didExitRegion(CLRegion )region NSLog(ldquoEXIT REGION) [manager stopRangingBeaconsInRegion(CLBeaconRegion )region]

DevCamp

- (void)locationManager(CLLocationManager )manager didRangeBeacons(NSArray )beacons inRegion(CLBeaconRegion )region for (CLBeacon beacon in beacons) NSLog( zd f beaconmajor beaconminor [Unknown Immediate Near Far][beaconproximity] beaconrssi beaconaccuracy)

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 12: iBeacons - the new low-powered way of location awareness

DevCamp

Connectionless

Devices do not need to maintain a connection for useful information to be exchanged quickly

between them

The connectionless model solves these problems by not defining the state of a connection but the state of the device

DevCamp

Stateless

Any client can send any request at any time and the server will respond to the same

request in exactly the same way regardless of which client made the request

DevCamp

Packet structure

DevCamp

Advertising packet

bull Preamble - 1 Byte - fixed 8bit to synchronize bit timing and set radiorsquos automatic gain control 101010101 or 010101010

bull Access Address - 4 Bytes - 32 fixed and random bit 0x8E89BED6 (that in binary is 01101011011111011001000101110001 The preamble would be 01010101)

bull Header - 1 Byte - to describe the contents of packet

bull Length - 1 Byte - to describe the payload length

bull CRC - 3 Bytes checksum calculated over PDU

bull PDU (Protocol Data Unit) - 37 Bytes

DevCamp

iBeacon

DevCamp

iBeacon is a new technology that extends Location Services in iOS

iBeacons provide a way to create and monitor beacons that advertise certain identifying information using Bluetooth

low energy wireless technology

(ref iOS 7 Understanding Location Services - Apple)

DevCamp

example of iBeacon PDU9F436059ADC00201061AFF4C000215B9407F30F5F8466EAFF925556B57FE6D010000FFB6

9F436059ADC0 Beaconrsquos Bluetooth MAC address02 Length of the next field01 Flags field identifier06 Flags (LE General Discoverable Mode)1A Length of the next fieldFF Manufacturer Specific Data field identifier4C00 Applersquos ID0215 Two fixed bytesB9407F30F5F8466EAFF925556B57FE6D Proximity UUID0100 Major00FF MinorB6 Measured power

DevCamp

iOS Frameworks

iBeacon

Core Bluetooth

Core Location

DevCamp

iOS Classes

CLBeacon

CLLocationManagerCLLocationManagerDelegate

CBPeripheralManager

CBPeripheral

CBCentralManager

CLBeaconRegion

DevCamp

CLBeacon

Identifying the Beacon131313 proximityUUID property13 1313 major property13 1313 minor property13 Determining the Beacon Distance131313 proximity property13 1313 accuracy property13 1313 rssi property13

DevCamp

CLBeaconRegion

Initializing the Beacon Region13 ndash initWithProximityUUIDidentifier13 ndash initWithProximityUUIDmajoridentifier13 ndash initWithProximityUUIDmajorminoridentifier13 Accessing the Beacon Attributes131313 proximityUUID property13 1313 major property13 1313 minor property13 Delivering Beacon Notifications131313 notifyEntryStateOnDisplay property13 Getting Beacon Advertisement Data13 ndash peripheralDataWithMeasuredPower

DevCamp

Code

DevCamp

iDevice as an iBeacon

selfmanager = [[CBPeripheralManager alloc] initWithDelegateself queuenil] NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid major1234 minor12 identifierldquoMy regionrdquo] [selfmanager startAdvertising[region peripheralDataWithMeasuredPowernil]] [selfmanager stopAdvertising]

DevCamp

Monitoring amp Ranging

NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid identifierldquoMy regionrdquo] selfmanager = [[CLLocationManager alloc] init] selfmanagerdelegate = self [selfmanager startMonitoringForRegionregion] [selfmanager requestStateForRegionregion]

DevCamp

- (void)locationManager(CLLocationManager )manager didDetermineState(CLRegionState)state forRegion(CLRegion )region if (state == CLRegionStateInside) NSLog(ldquoINSIDE REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didEnterRegion(CLRegion )region NSLog(ldquoENTER REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didExitRegion(CLRegion )region NSLog(ldquoEXIT REGION) [manager stopRangingBeaconsInRegion(CLBeaconRegion )region]

DevCamp

- (void)locationManager(CLLocationManager )manager didRangeBeacons(NSArray )beacons inRegion(CLBeaconRegion )region for (CLBeacon beacon in beacons) NSLog( zd f beaconmajor beaconminor [Unknown Immediate Near Far][beaconproximity] beaconrssi beaconaccuracy)

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 13: iBeacons - the new low-powered way of location awareness

DevCamp

Stateless

Any client can send any request at any time and the server will respond to the same

request in exactly the same way regardless of which client made the request

DevCamp

Packet structure

DevCamp

Advertising packet

bull Preamble - 1 Byte - fixed 8bit to synchronize bit timing and set radiorsquos automatic gain control 101010101 or 010101010

bull Access Address - 4 Bytes - 32 fixed and random bit 0x8E89BED6 (that in binary is 01101011011111011001000101110001 The preamble would be 01010101)

bull Header - 1 Byte - to describe the contents of packet

bull Length - 1 Byte - to describe the payload length

bull CRC - 3 Bytes checksum calculated over PDU

bull PDU (Protocol Data Unit) - 37 Bytes

DevCamp

iBeacon

DevCamp

iBeacon is a new technology that extends Location Services in iOS

iBeacons provide a way to create and monitor beacons that advertise certain identifying information using Bluetooth

low energy wireless technology

(ref iOS 7 Understanding Location Services - Apple)

DevCamp

example of iBeacon PDU9F436059ADC00201061AFF4C000215B9407F30F5F8466EAFF925556B57FE6D010000FFB6

9F436059ADC0 Beaconrsquos Bluetooth MAC address02 Length of the next field01 Flags field identifier06 Flags (LE General Discoverable Mode)1A Length of the next fieldFF Manufacturer Specific Data field identifier4C00 Applersquos ID0215 Two fixed bytesB9407F30F5F8466EAFF925556B57FE6D Proximity UUID0100 Major00FF MinorB6 Measured power

DevCamp

iOS Frameworks

iBeacon

Core Bluetooth

Core Location

DevCamp

iOS Classes

CLBeacon

CLLocationManagerCLLocationManagerDelegate

CBPeripheralManager

CBPeripheral

CBCentralManager

CLBeaconRegion

DevCamp

CLBeacon

Identifying the Beacon131313 proximityUUID property13 1313 major property13 1313 minor property13 Determining the Beacon Distance131313 proximity property13 1313 accuracy property13 1313 rssi property13

DevCamp

CLBeaconRegion

Initializing the Beacon Region13 ndash initWithProximityUUIDidentifier13 ndash initWithProximityUUIDmajoridentifier13 ndash initWithProximityUUIDmajorminoridentifier13 Accessing the Beacon Attributes131313 proximityUUID property13 1313 major property13 1313 minor property13 Delivering Beacon Notifications131313 notifyEntryStateOnDisplay property13 Getting Beacon Advertisement Data13 ndash peripheralDataWithMeasuredPower

DevCamp

Code

DevCamp

iDevice as an iBeacon

selfmanager = [[CBPeripheralManager alloc] initWithDelegateself queuenil] NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid major1234 minor12 identifierldquoMy regionrdquo] [selfmanager startAdvertising[region peripheralDataWithMeasuredPowernil]] [selfmanager stopAdvertising]

DevCamp

Monitoring amp Ranging

NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid identifierldquoMy regionrdquo] selfmanager = [[CLLocationManager alloc] init] selfmanagerdelegate = self [selfmanager startMonitoringForRegionregion] [selfmanager requestStateForRegionregion]

DevCamp

- (void)locationManager(CLLocationManager )manager didDetermineState(CLRegionState)state forRegion(CLRegion )region if (state == CLRegionStateInside) NSLog(ldquoINSIDE REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didEnterRegion(CLRegion )region NSLog(ldquoENTER REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didExitRegion(CLRegion )region NSLog(ldquoEXIT REGION) [manager stopRangingBeaconsInRegion(CLBeaconRegion )region]

DevCamp

- (void)locationManager(CLLocationManager )manager didRangeBeacons(NSArray )beacons inRegion(CLBeaconRegion )region for (CLBeacon beacon in beacons) NSLog( zd f beaconmajor beaconminor [Unknown Immediate Near Far][beaconproximity] beaconrssi beaconaccuracy)

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 14: iBeacons - the new low-powered way of location awareness

DevCamp

Packet structure

DevCamp

Advertising packet

bull Preamble - 1 Byte - fixed 8bit to synchronize bit timing and set radiorsquos automatic gain control 101010101 or 010101010

bull Access Address - 4 Bytes - 32 fixed and random bit 0x8E89BED6 (that in binary is 01101011011111011001000101110001 The preamble would be 01010101)

bull Header - 1 Byte - to describe the contents of packet

bull Length - 1 Byte - to describe the payload length

bull CRC - 3 Bytes checksum calculated over PDU

bull PDU (Protocol Data Unit) - 37 Bytes

DevCamp

iBeacon

DevCamp

iBeacon is a new technology that extends Location Services in iOS

iBeacons provide a way to create and monitor beacons that advertise certain identifying information using Bluetooth

low energy wireless technology

(ref iOS 7 Understanding Location Services - Apple)

DevCamp

example of iBeacon PDU9F436059ADC00201061AFF4C000215B9407F30F5F8466EAFF925556B57FE6D010000FFB6

9F436059ADC0 Beaconrsquos Bluetooth MAC address02 Length of the next field01 Flags field identifier06 Flags (LE General Discoverable Mode)1A Length of the next fieldFF Manufacturer Specific Data field identifier4C00 Applersquos ID0215 Two fixed bytesB9407F30F5F8466EAFF925556B57FE6D Proximity UUID0100 Major00FF MinorB6 Measured power

DevCamp

iOS Frameworks

iBeacon

Core Bluetooth

Core Location

DevCamp

iOS Classes

CLBeacon

CLLocationManagerCLLocationManagerDelegate

CBPeripheralManager

CBPeripheral

CBCentralManager

CLBeaconRegion

DevCamp

CLBeacon

Identifying the Beacon131313 proximityUUID property13 1313 major property13 1313 minor property13 Determining the Beacon Distance131313 proximity property13 1313 accuracy property13 1313 rssi property13

DevCamp

CLBeaconRegion

Initializing the Beacon Region13 ndash initWithProximityUUIDidentifier13 ndash initWithProximityUUIDmajoridentifier13 ndash initWithProximityUUIDmajorminoridentifier13 Accessing the Beacon Attributes131313 proximityUUID property13 1313 major property13 1313 minor property13 Delivering Beacon Notifications131313 notifyEntryStateOnDisplay property13 Getting Beacon Advertisement Data13 ndash peripheralDataWithMeasuredPower

DevCamp

Code

DevCamp

iDevice as an iBeacon

selfmanager = [[CBPeripheralManager alloc] initWithDelegateself queuenil] NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid major1234 minor12 identifierldquoMy regionrdquo] [selfmanager startAdvertising[region peripheralDataWithMeasuredPowernil]] [selfmanager stopAdvertising]

DevCamp

Monitoring amp Ranging

NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid identifierldquoMy regionrdquo] selfmanager = [[CLLocationManager alloc] init] selfmanagerdelegate = self [selfmanager startMonitoringForRegionregion] [selfmanager requestStateForRegionregion]

DevCamp

- (void)locationManager(CLLocationManager )manager didDetermineState(CLRegionState)state forRegion(CLRegion )region if (state == CLRegionStateInside) NSLog(ldquoINSIDE REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didEnterRegion(CLRegion )region NSLog(ldquoENTER REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didExitRegion(CLRegion )region NSLog(ldquoEXIT REGION) [manager stopRangingBeaconsInRegion(CLBeaconRegion )region]

DevCamp

- (void)locationManager(CLLocationManager )manager didRangeBeacons(NSArray )beacons inRegion(CLBeaconRegion )region for (CLBeacon beacon in beacons) NSLog( zd f beaconmajor beaconminor [Unknown Immediate Near Far][beaconproximity] beaconrssi beaconaccuracy)

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 15: iBeacons - the new low-powered way of location awareness

DevCamp

Advertising packet

bull Preamble - 1 Byte - fixed 8bit to synchronize bit timing and set radiorsquos automatic gain control 101010101 or 010101010

bull Access Address - 4 Bytes - 32 fixed and random bit 0x8E89BED6 (that in binary is 01101011011111011001000101110001 The preamble would be 01010101)

bull Header - 1 Byte - to describe the contents of packet

bull Length - 1 Byte - to describe the payload length

bull CRC - 3 Bytes checksum calculated over PDU

bull PDU (Protocol Data Unit) - 37 Bytes

DevCamp

iBeacon

DevCamp

iBeacon is a new technology that extends Location Services in iOS

iBeacons provide a way to create and monitor beacons that advertise certain identifying information using Bluetooth

low energy wireless technology

(ref iOS 7 Understanding Location Services - Apple)

DevCamp

example of iBeacon PDU9F436059ADC00201061AFF4C000215B9407F30F5F8466EAFF925556B57FE6D010000FFB6

9F436059ADC0 Beaconrsquos Bluetooth MAC address02 Length of the next field01 Flags field identifier06 Flags (LE General Discoverable Mode)1A Length of the next fieldFF Manufacturer Specific Data field identifier4C00 Applersquos ID0215 Two fixed bytesB9407F30F5F8466EAFF925556B57FE6D Proximity UUID0100 Major00FF MinorB6 Measured power

DevCamp

iOS Frameworks

iBeacon

Core Bluetooth

Core Location

DevCamp

iOS Classes

CLBeacon

CLLocationManagerCLLocationManagerDelegate

CBPeripheralManager

CBPeripheral

CBCentralManager

CLBeaconRegion

DevCamp

CLBeacon

Identifying the Beacon131313 proximityUUID property13 1313 major property13 1313 minor property13 Determining the Beacon Distance131313 proximity property13 1313 accuracy property13 1313 rssi property13

DevCamp

CLBeaconRegion

Initializing the Beacon Region13 ndash initWithProximityUUIDidentifier13 ndash initWithProximityUUIDmajoridentifier13 ndash initWithProximityUUIDmajorminoridentifier13 Accessing the Beacon Attributes131313 proximityUUID property13 1313 major property13 1313 minor property13 Delivering Beacon Notifications131313 notifyEntryStateOnDisplay property13 Getting Beacon Advertisement Data13 ndash peripheralDataWithMeasuredPower

DevCamp

Code

DevCamp

iDevice as an iBeacon

selfmanager = [[CBPeripheralManager alloc] initWithDelegateself queuenil] NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid major1234 minor12 identifierldquoMy regionrdquo] [selfmanager startAdvertising[region peripheralDataWithMeasuredPowernil]] [selfmanager stopAdvertising]

DevCamp

Monitoring amp Ranging

NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid identifierldquoMy regionrdquo] selfmanager = [[CLLocationManager alloc] init] selfmanagerdelegate = self [selfmanager startMonitoringForRegionregion] [selfmanager requestStateForRegionregion]

DevCamp

- (void)locationManager(CLLocationManager )manager didDetermineState(CLRegionState)state forRegion(CLRegion )region if (state == CLRegionStateInside) NSLog(ldquoINSIDE REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didEnterRegion(CLRegion )region NSLog(ldquoENTER REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didExitRegion(CLRegion )region NSLog(ldquoEXIT REGION) [manager stopRangingBeaconsInRegion(CLBeaconRegion )region]

DevCamp

- (void)locationManager(CLLocationManager )manager didRangeBeacons(NSArray )beacons inRegion(CLBeaconRegion )region for (CLBeacon beacon in beacons) NSLog( zd f beaconmajor beaconminor [Unknown Immediate Near Far][beaconproximity] beaconrssi beaconaccuracy)

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 16: iBeacons - the new low-powered way of location awareness

DevCamp

iBeacon

DevCamp

iBeacon is a new technology that extends Location Services in iOS

iBeacons provide a way to create and monitor beacons that advertise certain identifying information using Bluetooth

low energy wireless technology

(ref iOS 7 Understanding Location Services - Apple)

DevCamp

example of iBeacon PDU9F436059ADC00201061AFF4C000215B9407F30F5F8466EAFF925556B57FE6D010000FFB6

9F436059ADC0 Beaconrsquos Bluetooth MAC address02 Length of the next field01 Flags field identifier06 Flags (LE General Discoverable Mode)1A Length of the next fieldFF Manufacturer Specific Data field identifier4C00 Applersquos ID0215 Two fixed bytesB9407F30F5F8466EAFF925556B57FE6D Proximity UUID0100 Major00FF MinorB6 Measured power

DevCamp

iOS Frameworks

iBeacon

Core Bluetooth

Core Location

DevCamp

iOS Classes

CLBeacon

CLLocationManagerCLLocationManagerDelegate

CBPeripheralManager

CBPeripheral

CBCentralManager

CLBeaconRegion

DevCamp

CLBeacon

Identifying the Beacon131313 proximityUUID property13 1313 major property13 1313 minor property13 Determining the Beacon Distance131313 proximity property13 1313 accuracy property13 1313 rssi property13

DevCamp

CLBeaconRegion

Initializing the Beacon Region13 ndash initWithProximityUUIDidentifier13 ndash initWithProximityUUIDmajoridentifier13 ndash initWithProximityUUIDmajorminoridentifier13 Accessing the Beacon Attributes131313 proximityUUID property13 1313 major property13 1313 minor property13 Delivering Beacon Notifications131313 notifyEntryStateOnDisplay property13 Getting Beacon Advertisement Data13 ndash peripheralDataWithMeasuredPower

DevCamp

Code

DevCamp

iDevice as an iBeacon

selfmanager = [[CBPeripheralManager alloc] initWithDelegateself queuenil] NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid major1234 minor12 identifierldquoMy regionrdquo] [selfmanager startAdvertising[region peripheralDataWithMeasuredPowernil]] [selfmanager stopAdvertising]

DevCamp

Monitoring amp Ranging

NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid identifierldquoMy regionrdquo] selfmanager = [[CLLocationManager alloc] init] selfmanagerdelegate = self [selfmanager startMonitoringForRegionregion] [selfmanager requestStateForRegionregion]

DevCamp

- (void)locationManager(CLLocationManager )manager didDetermineState(CLRegionState)state forRegion(CLRegion )region if (state == CLRegionStateInside) NSLog(ldquoINSIDE REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didEnterRegion(CLRegion )region NSLog(ldquoENTER REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didExitRegion(CLRegion )region NSLog(ldquoEXIT REGION) [manager stopRangingBeaconsInRegion(CLBeaconRegion )region]

DevCamp

- (void)locationManager(CLLocationManager )manager didRangeBeacons(NSArray )beacons inRegion(CLBeaconRegion )region for (CLBeacon beacon in beacons) NSLog( zd f beaconmajor beaconminor [Unknown Immediate Near Far][beaconproximity] beaconrssi beaconaccuracy)

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 17: iBeacons - the new low-powered way of location awareness

DevCamp

iBeacon is a new technology that extends Location Services in iOS

iBeacons provide a way to create and monitor beacons that advertise certain identifying information using Bluetooth

low energy wireless technology

(ref iOS 7 Understanding Location Services - Apple)

DevCamp

example of iBeacon PDU9F436059ADC00201061AFF4C000215B9407F30F5F8466EAFF925556B57FE6D010000FFB6

9F436059ADC0 Beaconrsquos Bluetooth MAC address02 Length of the next field01 Flags field identifier06 Flags (LE General Discoverable Mode)1A Length of the next fieldFF Manufacturer Specific Data field identifier4C00 Applersquos ID0215 Two fixed bytesB9407F30F5F8466EAFF925556B57FE6D Proximity UUID0100 Major00FF MinorB6 Measured power

DevCamp

iOS Frameworks

iBeacon

Core Bluetooth

Core Location

DevCamp

iOS Classes

CLBeacon

CLLocationManagerCLLocationManagerDelegate

CBPeripheralManager

CBPeripheral

CBCentralManager

CLBeaconRegion

DevCamp

CLBeacon

Identifying the Beacon131313 proximityUUID property13 1313 major property13 1313 minor property13 Determining the Beacon Distance131313 proximity property13 1313 accuracy property13 1313 rssi property13

DevCamp

CLBeaconRegion

Initializing the Beacon Region13 ndash initWithProximityUUIDidentifier13 ndash initWithProximityUUIDmajoridentifier13 ndash initWithProximityUUIDmajorminoridentifier13 Accessing the Beacon Attributes131313 proximityUUID property13 1313 major property13 1313 minor property13 Delivering Beacon Notifications131313 notifyEntryStateOnDisplay property13 Getting Beacon Advertisement Data13 ndash peripheralDataWithMeasuredPower

DevCamp

Code

DevCamp

iDevice as an iBeacon

selfmanager = [[CBPeripheralManager alloc] initWithDelegateself queuenil] NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid major1234 minor12 identifierldquoMy regionrdquo] [selfmanager startAdvertising[region peripheralDataWithMeasuredPowernil]] [selfmanager stopAdvertising]

DevCamp

Monitoring amp Ranging

NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid identifierldquoMy regionrdquo] selfmanager = [[CLLocationManager alloc] init] selfmanagerdelegate = self [selfmanager startMonitoringForRegionregion] [selfmanager requestStateForRegionregion]

DevCamp

- (void)locationManager(CLLocationManager )manager didDetermineState(CLRegionState)state forRegion(CLRegion )region if (state == CLRegionStateInside) NSLog(ldquoINSIDE REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didEnterRegion(CLRegion )region NSLog(ldquoENTER REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didExitRegion(CLRegion )region NSLog(ldquoEXIT REGION) [manager stopRangingBeaconsInRegion(CLBeaconRegion )region]

DevCamp

- (void)locationManager(CLLocationManager )manager didRangeBeacons(NSArray )beacons inRegion(CLBeaconRegion )region for (CLBeacon beacon in beacons) NSLog( zd f beaconmajor beaconminor [Unknown Immediate Near Far][beaconproximity] beaconrssi beaconaccuracy)

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 18: iBeacons - the new low-powered way of location awareness

DevCamp

example of iBeacon PDU9F436059ADC00201061AFF4C000215B9407F30F5F8466EAFF925556B57FE6D010000FFB6

9F436059ADC0 Beaconrsquos Bluetooth MAC address02 Length of the next field01 Flags field identifier06 Flags (LE General Discoverable Mode)1A Length of the next fieldFF Manufacturer Specific Data field identifier4C00 Applersquos ID0215 Two fixed bytesB9407F30F5F8466EAFF925556B57FE6D Proximity UUID0100 Major00FF MinorB6 Measured power

DevCamp

iOS Frameworks

iBeacon

Core Bluetooth

Core Location

DevCamp

iOS Classes

CLBeacon

CLLocationManagerCLLocationManagerDelegate

CBPeripheralManager

CBPeripheral

CBCentralManager

CLBeaconRegion

DevCamp

CLBeacon

Identifying the Beacon131313 proximityUUID property13 1313 major property13 1313 minor property13 Determining the Beacon Distance131313 proximity property13 1313 accuracy property13 1313 rssi property13

DevCamp

CLBeaconRegion

Initializing the Beacon Region13 ndash initWithProximityUUIDidentifier13 ndash initWithProximityUUIDmajoridentifier13 ndash initWithProximityUUIDmajorminoridentifier13 Accessing the Beacon Attributes131313 proximityUUID property13 1313 major property13 1313 minor property13 Delivering Beacon Notifications131313 notifyEntryStateOnDisplay property13 Getting Beacon Advertisement Data13 ndash peripheralDataWithMeasuredPower

DevCamp

Code

DevCamp

iDevice as an iBeacon

selfmanager = [[CBPeripheralManager alloc] initWithDelegateself queuenil] NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid major1234 minor12 identifierldquoMy regionrdquo] [selfmanager startAdvertising[region peripheralDataWithMeasuredPowernil]] [selfmanager stopAdvertising]

DevCamp

Monitoring amp Ranging

NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid identifierldquoMy regionrdquo] selfmanager = [[CLLocationManager alloc] init] selfmanagerdelegate = self [selfmanager startMonitoringForRegionregion] [selfmanager requestStateForRegionregion]

DevCamp

- (void)locationManager(CLLocationManager )manager didDetermineState(CLRegionState)state forRegion(CLRegion )region if (state == CLRegionStateInside) NSLog(ldquoINSIDE REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didEnterRegion(CLRegion )region NSLog(ldquoENTER REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didExitRegion(CLRegion )region NSLog(ldquoEXIT REGION) [manager stopRangingBeaconsInRegion(CLBeaconRegion )region]

DevCamp

- (void)locationManager(CLLocationManager )manager didRangeBeacons(NSArray )beacons inRegion(CLBeaconRegion )region for (CLBeacon beacon in beacons) NSLog( zd f beaconmajor beaconminor [Unknown Immediate Near Far][beaconproximity] beaconrssi beaconaccuracy)

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 19: iBeacons - the new low-powered way of location awareness

DevCamp

iOS Frameworks

iBeacon

Core Bluetooth

Core Location

DevCamp

iOS Classes

CLBeacon

CLLocationManagerCLLocationManagerDelegate

CBPeripheralManager

CBPeripheral

CBCentralManager

CLBeaconRegion

DevCamp

CLBeacon

Identifying the Beacon131313 proximityUUID property13 1313 major property13 1313 minor property13 Determining the Beacon Distance131313 proximity property13 1313 accuracy property13 1313 rssi property13

DevCamp

CLBeaconRegion

Initializing the Beacon Region13 ndash initWithProximityUUIDidentifier13 ndash initWithProximityUUIDmajoridentifier13 ndash initWithProximityUUIDmajorminoridentifier13 Accessing the Beacon Attributes131313 proximityUUID property13 1313 major property13 1313 minor property13 Delivering Beacon Notifications131313 notifyEntryStateOnDisplay property13 Getting Beacon Advertisement Data13 ndash peripheralDataWithMeasuredPower

DevCamp

Code

DevCamp

iDevice as an iBeacon

selfmanager = [[CBPeripheralManager alloc] initWithDelegateself queuenil] NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid major1234 minor12 identifierldquoMy regionrdquo] [selfmanager startAdvertising[region peripheralDataWithMeasuredPowernil]] [selfmanager stopAdvertising]

DevCamp

Monitoring amp Ranging

NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid identifierldquoMy regionrdquo] selfmanager = [[CLLocationManager alloc] init] selfmanagerdelegate = self [selfmanager startMonitoringForRegionregion] [selfmanager requestStateForRegionregion]

DevCamp

- (void)locationManager(CLLocationManager )manager didDetermineState(CLRegionState)state forRegion(CLRegion )region if (state == CLRegionStateInside) NSLog(ldquoINSIDE REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didEnterRegion(CLRegion )region NSLog(ldquoENTER REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didExitRegion(CLRegion )region NSLog(ldquoEXIT REGION) [manager stopRangingBeaconsInRegion(CLBeaconRegion )region]

DevCamp

- (void)locationManager(CLLocationManager )manager didRangeBeacons(NSArray )beacons inRegion(CLBeaconRegion )region for (CLBeacon beacon in beacons) NSLog( zd f beaconmajor beaconminor [Unknown Immediate Near Far][beaconproximity] beaconrssi beaconaccuracy)

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 20: iBeacons - the new low-powered way of location awareness

DevCamp

iOS Classes

CLBeacon

CLLocationManagerCLLocationManagerDelegate

CBPeripheralManager

CBPeripheral

CBCentralManager

CLBeaconRegion

DevCamp

CLBeacon

Identifying the Beacon131313 proximityUUID property13 1313 major property13 1313 minor property13 Determining the Beacon Distance131313 proximity property13 1313 accuracy property13 1313 rssi property13

DevCamp

CLBeaconRegion

Initializing the Beacon Region13 ndash initWithProximityUUIDidentifier13 ndash initWithProximityUUIDmajoridentifier13 ndash initWithProximityUUIDmajorminoridentifier13 Accessing the Beacon Attributes131313 proximityUUID property13 1313 major property13 1313 minor property13 Delivering Beacon Notifications131313 notifyEntryStateOnDisplay property13 Getting Beacon Advertisement Data13 ndash peripheralDataWithMeasuredPower

DevCamp

Code

DevCamp

iDevice as an iBeacon

selfmanager = [[CBPeripheralManager alloc] initWithDelegateself queuenil] NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid major1234 minor12 identifierldquoMy regionrdquo] [selfmanager startAdvertising[region peripheralDataWithMeasuredPowernil]] [selfmanager stopAdvertising]

DevCamp

Monitoring amp Ranging

NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid identifierldquoMy regionrdquo] selfmanager = [[CLLocationManager alloc] init] selfmanagerdelegate = self [selfmanager startMonitoringForRegionregion] [selfmanager requestStateForRegionregion]

DevCamp

- (void)locationManager(CLLocationManager )manager didDetermineState(CLRegionState)state forRegion(CLRegion )region if (state == CLRegionStateInside) NSLog(ldquoINSIDE REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didEnterRegion(CLRegion )region NSLog(ldquoENTER REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didExitRegion(CLRegion )region NSLog(ldquoEXIT REGION) [manager stopRangingBeaconsInRegion(CLBeaconRegion )region]

DevCamp

- (void)locationManager(CLLocationManager )manager didRangeBeacons(NSArray )beacons inRegion(CLBeaconRegion )region for (CLBeacon beacon in beacons) NSLog( zd f beaconmajor beaconminor [Unknown Immediate Near Far][beaconproximity] beaconrssi beaconaccuracy)

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 21: iBeacons - the new low-powered way of location awareness

DevCamp

CLBeacon

Identifying the Beacon131313 proximityUUID property13 1313 major property13 1313 minor property13 Determining the Beacon Distance131313 proximity property13 1313 accuracy property13 1313 rssi property13

DevCamp

CLBeaconRegion

Initializing the Beacon Region13 ndash initWithProximityUUIDidentifier13 ndash initWithProximityUUIDmajoridentifier13 ndash initWithProximityUUIDmajorminoridentifier13 Accessing the Beacon Attributes131313 proximityUUID property13 1313 major property13 1313 minor property13 Delivering Beacon Notifications131313 notifyEntryStateOnDisplay property13 Getting Beacon Advertisement Data13 ndash peripheralDataWithMeasuredPower

DevCamp

Code

DevCamp

iDevice as an iBeacon

selfmanager = [[CBPeripheralManager alloc] initWithDelegateself queuenil] NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid major1234 minor12 identifierldquoMy regionrdquo] [selfmanager startAdvertising[region peripheralDataWithMeasuredPowernil]] [selfmanager stopAdvertising]

DevCamp

Monitoring amp Ranging

NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid identifierldquoMy regionrdquo] selfmanager = [[CLLocationManager alloc] init] selfmanagerdelegate = self [selfmanager startMonitoringForRegionregion] [selfmanager requestStateForRegionregion]

DevCamp

- (void)locationManager(CLLocationManager )manager didDetermineState(CLRegionState)state forRegion(CLRegion )region if (state == CLRegionStateInside) NSLog(ldquoINSIDE REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didEnterRegion(CLRegion )region NSLog(ldquoENTER REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didExitRegion(CLRegion )region NSLog(ldquoEXIT REGION) [manager stopRangingBeaconsInRegion(CLBeaconRegion )region]

DevCamp

- (void)locationManager(CLLocationManager )manager didRangeBeacons(NSArray )beacons inRegion(CLBeaconRegion )region for (CLBeacon beacon in beacons) NSLog( zd f beaconmajor beaconminor [Unknown Immediate Near Far][beaconproximity] beaconrssi beaconaccuracy)

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 22: iBeacons - the new low-powered way of location awareness

DevCamp

CLBeaconRegion

Initializing the Beacon Region13 ndash initWithProximityUUIDidentifier13 ndash initWithProximityUUIDmajoridentifier13 ndash initWithProximityUUIDmajorminoridentifier13 Accessing the Beacon Attributes131313 proximityUUID property13 1313 major property13 1313 minor property13 Delivering Beacon Notifications131313 notifyEntryStateOnDisplay property13 Getting Beacon Advertisement Data13 ndash peripheralDataWithMeasuredPower

DevCamp

Code

DevCamp

iDevice as an iBeacon

selfmanager = [[CBPeripheralManager alloc] initWithDelegateself queuenil] NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid major1234 minor12 identifierldquoMy regionrdquo] [selfmanager startAdvertising[region peripheralDataWithMeasuredPowernil]] [selfmanager stopAdvertising]

DevCamp

Monitoring amp Ranging

NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid identifierldquoMy regionrdquo] selfmanager = [[CLLocationManager alloc] init] selfmanagerdelegate = self [selfmanager startMonitoringForRegionregion] [selfmanager requestStateForRegionregion]

DevCamp

- (void)locationManager(CLLocationManager )manager didDetermineState(CLRegionState)state forRegion(CLRegion )region if (state == CLRegionStateInside) NSLog(ldquoINSIDE REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didEnterRegion(CLRegion )region NSLog(ldquoENTER REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didExitRegion(CLRegion )region NSLog(ldquoEXIT REGION) [manager stopRangingBeaconsInRegion(CLBeaconRegion )region]

DevCamp

- (void)locationManager(CLLocationManager )manager didRangeBeacons(NSArray )beacons inRegion(CLBeaconRegion )region for (CLBeacon beacon in beacons) NSLog( zd f beaconmajor beaconminor [Unknown Immediate Near Far][beaconproximity] beaconrssi beaconaccuracy)

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 23: iBeacons - the new low-powered way of location awareness

DevCamp

Code

DevCamp

iDevice as an iBeacon

selfmanager = [[CBPeripheralManager alloc] initWithDelegateself queuenil] NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid major1234 minor12 identifierldquoMy regionrdquo] [selfmanager startAdvertising[region peripheralDataWithMeasuredPowernil]] [selfmanager stopAdvertising]

DevCamp

Monitoring amp Ranging

NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid identifierldquoMy regionrdquo] selfmanager = [[CLLocationManager alloc] init] selfmanagerdelegate = self [selfmanager startMonitoringForRegionregion] [selfmanager requestStateForRegionregion]

DevCamp

- (void)locationManager(CLLocationManager )manager didDetermineState(CLRegionState)state forRegion(CLRegion )region if (state == CLRegionStateInside) NSLog(ldquoINSIDE REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didEnterRegion(CLRegion )region NSLog(ldquoENTER REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didExitRegion(CLRegion )region NSLog(ldquoEXIT REGION) [manager stopRangingBeaconsInRegion(CLBeaconRegion )region]

DevCamp

- (void)locationManager(CLLocationManager )manager didRangeBeacons(NSArray )beacons inRegion(CLBeaconRegion )region for (CLBeacon beacon in beacons) NSLog( zd f beaconmajor beaconminor [Unknown Immediate Near Far][beaconproximity] beaconrssi beaconaccuracy)

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 24: iBeacons - the new low-powered way of location awareness

DevCamp

iDevice as an iBeacon

selfmanager = [[CBPeripheralManager alloc] initWithDelegateself queuenil] NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid major1234 minor12 identifierldquoMy regionrdquo] [selfmanager startAdvertising[region peripheralDataWithMeasuredPowernil]] [selfmanager stopAdvertising]

DevCamp

Monitoring amp Ranging

NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid identifierldquoMy regionrdquo] selfmanager = [[CLLocationManager alloc] init] selfmanagerdelegate = self [selfmanager startMonitoringForRegionregion] [selfmanager requestStateForRegionregion]

DevCamp

- (void)locationManager(CLLocationManager )manager didDetermineState(CLRegionState)state forRegion(CLRegion )region if (state == CLRegionStateInside) NSLog(ldquoINSIDE REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didEnterRegion(CLRegion )region NSLog(ldquoENTER REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didExitRegion(CLRegion )region NSLog(ldquoEXIT REGION) [manager stopRangingBeaconsInRegion(CLBeaconRegion )region]

DevCamp

- (void)locationManager(CLLocationManager )manager didRangeBeacons(NSArray )beacons inRegion(CLBeaconRegion )region for (CLBeacon beacon in beacons) NSLog( zd f beaconmajor beaconminor [Unknown Immediate Near Far][beaconproximity] beaconrssi beaconaccuracy)

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 25: iBeacons - the new low-powered way of location awareness

DevCamp

Monitoring amp Ranging

NSUUID uuid = [[NSUUID alloc] initWithUUIDStringldquo666972D4-9BE7-4E7D-A1D4-973E1285BE19] CLBeaconRegion region = [[CLBeaconRegion alloc] initWithProximityUUIDuuid identifierldquoMy regionrdquo] selfmanager = [[CLLocationManager alloc] init] selfmanagerdelegate = self [selfmanager startMonitoringForRegionregion] [selfmanager requestStateForRegionregion]

DevCamp

- (void)locationManager(CLLocationManager )manager didDetermineState(CLRegionState)state forRegion(CLRegion )region if (state == CLRegionStateInside) NSLog(ldquoINSIDE REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didEnterRegion(CLRegion )region NSLog(ldquoENTER REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didExitRegion(CLRegion )region NSLog(ldquoEXIT REGION) [manager stopRangingBeaconsInRegion(CLBeaconRegion )region]

DevCamp

- (void)locationManager(CLLocationManager )manager didRangeBeacons(NSArray )beacons inRegion(CLBeaconRegion )region for (CLBeacon beacon in beacons) NSLog( zd f beaconmajor beaconminor [Unknown Immediate Near Far][beaconproximity] beaconrssi beaconaccuracy)

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 26: iBeacons - the new low-powered way of location awareness

DevCamp

- (void)locationManager(CLLocationManager )manager didDetermineState(CLRegionState)state forRegion(CLRegion )region if (state == CLRegionStateInside) NSLog(ldquoINSIDE REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didEnterRegion(CLRegion )region NSLog(ldquoENTER REGION) [manager startRangingBeaconsInRegion(CLBeaconRegion )region] - (void)locationManager(CLLocationManager )manager didExitRegion(CLRegion )region NSLog(ldquoEXIT REGION) [manager stopRangingBeaconsInRegion(CLBeaconRegion )region]

DevCamp

- (void)locationManager(CLLocationManager )manager didRangeBeacons(NSArray )beacons inRegion(CLBeaconRegion )region for (CLBeacon beacon in beacons) NSLog( zd f beaconmajor beaconminor [Unknown Immediate Near Far][beaconproximity] beaconrssi beaconaccuracy)

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 27: iBeacons - the new low-powered way of location awareness

DevCamp

- (void)locationManager(CLLocationManager )manager didRangeBeacons(NSArray )beacons inRegion(CLBeaconRegion )region for (CLBeacon beacon in beacons) NSLog( zd f beaconmajor beaconminor [Unknown Immediate Near Far][beaconproximity] beaconrssi beaconaccuracy)

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 28: iBeacons - the new low-powered way of location awareness

DevCamp

Background mode

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 29: iBeacons - the new low-powered way of location awareness

DevCamp

Background region monitoring

If a region boundary is crossed while an app isnrsquot running that app is relaunched into the background to handle the event

In iOS regions associated with your app are tracked at all times including when the app isnrsquot running

Similarly if the app is suspended when the event occurs itrsquos woken up and given a short amount of time (around 10 seconds) to handle the event

When necessary an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler method of the UIApplication class

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 30: iBeacons - the new low-powered way of location awareness

DevCamp

buthellip

Region monitoring in background takes very long time to notify the region change (up to 15min)

there is a little trick

Set the notifyEntryStateOnDisplay to YES

the location manager sends beacon notifications when the user turns on the display and the device is already inside the region These

notifications are sent even if your app is not running

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 31: iBeacons - the new low-powered way of location awareness

DevCamp

Limitations

1 Signal interference2 Very small data packets3 Easy to sniff advertising packets 4 Easy to clone a beacon

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 32: iBeacons - the new low-powered way of location awareness

DevCamp

Internet amp Books

httpdeveloperradiusnetworkscom

httpestimotecom

httpswwwbluetoothorgen-usspecificationadopted-specifications

ldquoBluetooth Low Energy The Developers Handbookrdquo (Heydon Robin)

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 33: iBeacons - the new low-powered way of location awareness

DevCamp

Link

facebookcompragmamark13facebookcomgroupspragmamark13 pragmamarkorg13httppragmamarkorg

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg

Page 34: iBeacons - the new low-powered way of location awareness

DevCamp

NSLog(rdquoThank yourdquo)

stefanozanettipragmamarkorg