xamarin ibeacon mini-hack using estimote ibeacons
TRANSCRIPT
A little less conversation, a little
more iBeaconsEstimote iBeacons mini-hack
Jim Bennett@JimBobBennetthttp://JimBobBennett.io
What are we going to do tonight?
• A quick overview of iBeacons
• The cool things you can do with them
• Hands on with the Estimote Xamarin component
• Lets play! Team up and build a treasure hunt app, and win some beacons
What are iBeacons?• Bluetooth LE devices
• Broadcast a fixed format message defined by Apple on a periodic basis
• Message has an Id, version (major, minor), measured power
• Multiple iBeacons can have the same Id, versions can be use to distinguish different iBeacons
How do they interact with your app?• Apple defines an API to interact
with iBeacons as part of CoreLocation
• Apps can register to monitor a region - all beacons with a given Id
• Monitoring notifies when an iBeacon moves in or out of range
• Monitoring can happen in the background and will launch your app
• Once your app is in the foreground, you can range the iBeacons to get their proximity/distance as it changes
What does this mean for your app?
• Indoor location awareness
• Context awareness
What apps can you build to take advantage of
this?• Museum guide - app knows which exhibit you are standing next to and plays the correct audio
• Theatre location - app can pinpoint your location and direct you to your seat
• Shopping - notifications of special offers when you are next to the items on offer
• Respond to indoor location - turn your lights off when you put your phone down on your bedside table, notify friends when you are home safe
Problems!• Security - anyone can read your beacon by
scanning for Bluetooth devices and spoof your id
• Power - some iBeacons run off the mains so need socket, battery powered ones will die and need replacing
• Accuracy - not very, for example in a busy location people can decrease signal strength
• No simulator support - need an actual device for debugging
Estimote iBeacons• Estimote have extended the
capabilities of their iBeacons
• Distance measurements, flip to power off
• Indoor location SDK
• Android support
• Xamarin component
• Nearables
• Strong developer community support
• Other iBeacon providers are available
Best of all!Free beacons!
2 dev kits to be given away, everyone gets 10% off their first Estimote order and Stickers for everyone
CodeExamples at:
https://github.com/jimbobbennett/iBeaconsMiniHack
https://gist.github.com/jimbobbennett
Step 1 - add the component
• Install the Estimote SDK for iOS component
Step 2 - add the permissions
• Need either NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription set
Step 3 - Setup the BeaconManager and
authorise
• Create a BeaconManager - this wraps CLLocationManager
• Listen for changes to the authorisation status
• Request permission
Step 4 - Start ranging beacons
• To range you need to specify a region
• Each region is based on a UUID and optionally a major and minor version
• Each region must have a name and you can use this in the event handler to correctly handle the ranging of beacons from multiple regions
• By default all brand new Estimote iBeacons have a UUID ofB9407F30-F5F8-466E-AFF9-25556B57FE6D
Step 5 - Handle the ranged beacons
• The Ranged event provides a list of beacons
• Contains just the one that was ranged, or all of them depending on the setup
Gotcha’s• Distance of -1
• Means not enough signal or advertising packets - ramp up the broadcast rate
• Checking for equality
• Beacons are equal if the UUID/version matches. Beacons in the event args are new instances.
• Not working - check authorization!
• Make sure your code requests authorization and handles the denied case.
Lets find some treasure!Your challenge:
Form small teams - ideally 3 to a team
There will be 3 beacons hidden in another room
Write an app to find the beacons and record the letters written on each
Each team will enter the room one at a time - the fastest team to locate them all wins some booty - an Estimote iBeacons dev kit with 3
iBeacons - worth $100
Afterwards each team will show off their results. The team with the best app wins
another Estimote dev kit
Useful links• http://estimote.com
• https://gist.github.com/jimbobbennett/07fb701789abce7bdc8b
• https://github.com/jimbobbennett/iBeaconsMiniHack
• https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/LocationAwarenessPG/RegionMonitoring/RegionMonitoring.html#//apple_ref/doc/uid/TP40009497-CH9-SW1
• http://motzcod.es/post/105283789517/ios-ibeacon-background-region-monitoring
• http://motzcod.es/post/97662738237/scanning-for-ibeacons-in-ios-8
• https://www.brooklynmuseum.org/community/blogosphere/2015/02/04/the-realities-of-installing-ibeacon-to-scale/