Slides from the Birmingham Xamarin user group meeting:
A little less conversation, a little more iBeacons…
iBeacons are a cool technology that allows you to add location awareness to you apps, not based on your location on a map, but based on your proximity to iBeacons, be they at a fixed or moving point. They allow your apps to have an accurate understanding of where you are both inside and out, from sending you offers when you are in a shop to knowing where you are in a sports stadium so you can be directed to your seat. iBeacons are a big up and coming thing - even Facebook are now sending them out to businesses so their app can become location aware. Companies like Estimote are creating and extending iBeacons to bring even more amazing features to the developer.
In this mini-hack I’ll be talking briefly about this technology and a little about it’s uses, then we’ll hit the code. Bring a Mac laptop, iPhone and lightning cable, and team up with others in building a treasure hunt app using the Estimote iOS Xamarin component and Estimote iBeacons. There will be a prize of an Estimote developer kit or two (containing 3 iBeacons, worth $100 each) for the team that can complete the treasure hunt the fastest.
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Xamarin iBeacon Mini-hack using Estimote iBeacons
1. A little less conversation,
a little more iBeacons
Estimote iBeacons mini-hack
Jim Bennett
@JimBobBennett
http://JimBobBennett.io
2. 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
3. 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
4. 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
5. What does this mean for
your app?
• Indoor location awareness
• Context awareness
6. 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
7. 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
8. 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
9. Best of all!
Free beacons!
2 dev kits to be given away, everyone gets 10% off their first Estimote
order and Stickers for everyone
11. Step 1 - add the component
• Install the Estimote SDK for iOS component
12. Step 2 - add the permissions
• Need either NSLocationWhenInUseUsageDescription or
NSLocationAlwaysUsageDescription set
13. Step 3 - Setup the
BeaconManager and
authorise
• Create a BeaconManager - this wraps CLLocationManager
• Listen for changes to the authorisation status
• Request permission
14. 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 of
B9407F30-F5F8-466E-AFF9-25556B57FE6D
15. 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
16. 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.
17. 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
At the end of this slide - organise everyone into teams, minimum 1 iOS dev per team, ideally max 3 to a team
iBeacons use Bluetooth 4.0 LE. Very low power so can run for a long time. Estimote reckon 2 years for their battery powered iBeacons.
The frequency of the broadcast can vary - less time to save battery life. Apple recommends 100ms.
The Id is a 128bit UUID, version is 2 16-bit integers for major and minor
Multiple beacons with the same Id can be used to indicate the same thing to allow discovery over a wider area than the broadcast power of a single iBeacon.
Monitoring detects iBeacons moving into an our of fixed ranges. Once your app is in the foreground you can range the iBeacons to get notifications of distance changes.
The iBeacon message contains the measured power. The API provides a value for the RSSI - relative signal strength indicator. This is the power detected by the iOS device and can be used to calculate the approximate distance.
Distance is only approximate and is based on assuming empty air - things in the way can reduce the detected signal - furniture, people etc.
Ranging will call a method regularly when your app is in the foreground to provide the updated distance.
Indoor location - an app can know where it is without accurate GPS. Useful for finding your seat in a stadium, directing you around a hospital etc.
Context aware - it can resolve the id to a context, such as a painting in a gallery.
Security can be a problem for payments - another beacon can broadcast the same id and the wrong person pays.
Battery is an issue with large installations - imaging having to replace them regularly in an art gallery where they would be hidden behind pictures.
Not accurate with people in the way - a problem in busy areas like shops, museums and art galleries. Brooklyn Museum has a great article on this.
I don’t work for Estimote, just like their products.
Custom SDK on top of iOS CoreLocation, cloud offering to provide CMS for beacon ids
Indoor location to easily plot location in a room
Android support similar to iOS support and getting closer all the time
Strong Xamarin support, strong dev community.
Nearables provide temperature, movement triggers
Estimote have provided 2 iBeacon developer kits with $100 each to be given away at this talk.
They will also provide 10% off on your first order with them, just email them at contact@estimote.com
Also - free stickers!
New single page iOS app.
Need correct identifier so it can run on a device
Install the component and it shows a nice getting started guide
Set the relevant item in the info.plist. It’s not a default option so needs to be added as a new property
The contents of the string is shown in the alert when the app asks for permission
Visual studio users - you will need to edit the plist source directly.
If the app has never requested authorisation then the request will pop up an alert to the user.
RequesWhenInUseAuthorization or RequestAlwaysAuthorization - and the relevant info.plist item should be there.
Default authorization state is NotDetermined. Event will fire with a status of AuthorizedAlways, AuthorizedWhenInUse, Denied.
Denied means the user has to turn it on in settings - this happens when they reject the alert - you need to handle this case!
You can range up to 20 regions.
Every beacon that matches the region will be detected on every beacon signal - this rate is set on the beacon. Faster means better ranging but lower battery life.
As each signal is detected the event is fired. It can be fired once per detected signal or the event can include all ranged beacons in one bundle.
The UUID of a beacon can be configured using the Estimote SDK or app.
Default UUID is on a gist - https://gist.github.com/jimbobbennett/9d815bafe4dd432f7e09
Broadcast rates can be set in code or from the Estimote app but needs authorisation. Each iBeacon is assigned to an account and you need to log into that account to change beacon settings. This stops malicious changes.
When storing beacons in a list beware the comparison - the event provides new instances so although they are equal by ID, the properties are different.