[#XAMARIN] First steps with #Estimote Beacons and #VS2015

Hello!

Now that I have a pair of beacons up and running, next step is to create an app to see how you can interact with them. For this sample, I will create an app using Xamarin Forms and I will test the app with Android as target (my iOS build and deploy environment is on Luis hands)

So, our Xamarin Forms Solution has multiple projects, a common project and the custom implementations for Android, iOS and Windows Phone. In each one of the projects you can add external components that will help us work with the beacons. A quick search shows us that we have several available Estimote NuGet packages to work with.

Estimote Components

The first step is to add the Estimote SDK for Android into the Android project. A search of the components will show us this component.

Clipboard01

The application that we will make will be a Xamarin Forms one, so if you also want to implement it in iOS you can add the component for iOS

Clipboard01

There is a common NuGet Package which we must add into the Forms app, and in the Android and iOS, this package is ACR Estimote PlugIn for Xamarin
Let’s go back to the Android project, in this one we must enable permissions to work with BlueTooth

  • BLUETOOTH
  • BLUETOOTH_ADMIN

Clipboard01

And now is time to add a couple of lines of code. In the main app, I’ll add a stack with 3 labels

  • private Label _labelTitle;
  • private Label _labelContent;
  • private Label _labelStatus;

In the app Start(), I’ll init the interaction with the Beacons (line 48). If everything works properly, we can start to suscribe to the events Raged and RegionStatusChanged (lines 59 and 60)

Clipboard03

When the app detects a beacon, we will receive a message with the same information. The beacons work with a concept that the regions are (see external links), a region can be defined with one or more beacons. The primary way of identifying them consists of 3 options

  • With only UUID: it consists of all beacons with a given UUID. For example: a region defined with default Estimote UUID would consist of all Estimote Beacons with unchanged UUID.
  • With UUID and Major: it consists of all beacons using a specific combination of UUID and Major. For example: all Estimote Beacons with default UUID and Major set to 13579.
  • With UUID, Major and Minor: it consists of only a single beacon (Estimote Cloud prevents having two beacons with the same IDs). For example, one with default Estimote UUID, Major set to 13579 and Minor set to 2468.

In the RegionStatusChanged() event, we will capture the change of region. The new region will show us information of the UUID, Major and Minor.

Clipboard05

With these few lines of code we can already test our app. At this time, we can deploy our app on the emulator. But at the same we will see that Visual Studio 2015 emulator does not support BlueTooth emulation.

Clipboard02

So, in the next post I will show how the app on a real device.

Greetings @ Madrid

-El Bruno

References

Advertisement

4 comments

  1. Hello, I was wondering if your friend Luis ever did this for iOS. Is there a link where I can find this for iOS version?

    Like

    1. Hi Lala

      the code should work the same in an iOS app. You only need to change the Xamarin component and use the iOS one instead of the android.

      Regards
      -El Bruno

      Like

Leave a Reply to Lala Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: