Get started with beacons in your UWP App

With Windows 10 Microsoft added support for Beacons. In this blogpost I will tell you how to get started. It’s very easy! And since writing an UWP app it will work on your pc, tablet but ofcourse also on your phone.


  • A beacon, A little device that sends the signal
  • A Bluetooth LE enabled device

I am using this beacon in combination with my surface 3 pro and my Lumia 930.

First the setup; this one is little tricky. You need to enable Bluetooth for your app. In the past I was used to do this in the manifest designer where you could easily add capabilities but for some reason this seems to be missing. So you need to open the package.manifest with the xml editor. You can do this by right click on the file. Choose “Open with” and then from the list pick “Xml (Text) Editor”. In the Capability section you need to add: <DeviceCapability Name=”bluetooth” />

enter image description here

From here it’s getting pretty easy. Create an instance from BluetoothLEAdvertisementWatcher and add an event handler to the Received event and when you are ready call start

watcher = new BluetoothLEAdvertisementWatcher();
watcher.Received += Watcher_Received;

Now when a beacon is getting close the event will get fired. Here you get the data that is received from the beacon as Manufacturer data, signal strength and the timestamp of when the beacon signal was received. Code to parse the incoming data can look like this, I copied this from the Sample code Microsoft published at GitHub

// We can obtain various information about the advertisement we just received by accessing 
// the properties of the EventArgs class

// The timestamp of the event
DateTimeOffset timestamp = eventArgs.Timestamp;

// The type of advertisement
BluetoothLEAdvertisementType advertisementType = eventArgs.AdvertisementType;

// The received signal strength indicator (RSSI)
Int16 rssi = eventArgs.RawSignalStrengthInDBm;

// The local name of the advertising device contained within the payload, if any
string localName = eventArgs.Advertisement.LocalName;

// Check if there are any manufacturer-specific sections.
// If there is, print the raw data of the first manufacturer section (if there are multiple).
string manufacturerDataString = "";
var manufacturerSections = eventArgs.Advertisement.ManufacturerData;
if (manufacturerSections.Count > 0)
// Only print the first one of the list
var manufacturerData = manufacturerSections[0];
var data = new byte[manufacturerData.Data.Length];
using (var reader = DataReader.FromBuffer(manufacturerData.Data))
// Print the company ID + the raw data in hex format
manufacturerDataString = string.Format("0x{0}: {1}",

// Serialize UI update to the main UI thread
await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
// Display these information on the list
ReceivedAdvertisementListBox.Items.Add(string.Format("[{0}]: type={1}, rssi={2}, name={3}, manufacturerData=[{4}]",

The watcher now will fire the Received event for every beacon, but you can add filters. Filters can be placed on the manufacturer data, so you will just receive beacons that are created by your for example, but it’s also possible to place filters on the signal strength.

What next? With this code your app have to be running, but it’s also possible to make a BackgroundTask that gets triggered when you getting in range or out of range of a beacon. In a next blogpost I will show how you build this!

  •   @JenMsft like the concept. but too much details to go now. disabled it
  •   RT @dotMorten: I am an Edge user, but forcing users of Windows Mail to use Edge might be the most evil thing Microsoft have done in a long…
  •   @donasarkar impressive!
  •   RT @PyImageSearch: I am excited to announce that @Microsoft + @MSFTResearch are sponsoring PyImageConf 2018 and providing FREE pre-configur…
  •   @tfsbuck thanks :)
  •   @tfsbuck never mind.. figured it out, well the creator of the PR was able to restart the merge and in second attempt it worked
  •   @terrajobst @fonssonnemans @hermitdave @imjoshfree dark is for depressed people. agree with @fonssonnemans light team ftw
  •   @tfsbuck how long should it take to complete a pull request? can that take over 15 minutes? normally pretty fast (i mean instant)
  •   RT @windowsblog: Windows 10 SDK Preview Build 17115 now available
  •   RT @csharpfritz: Visual Studio 2017 Version 15.7 Preview 1