Language: JavaScript and HTML | VB/C#/C++ and XAML

Testing and debugging geofencing apps (Windows Runtime apps using C#/VB/C++ and XAML)

Applies to Windows and Windows Phone

Testing and debugging geofencing apps can be a challenge because they depend on a device's location. Here we outline several methods for testing both foreground and background geofences.

To debug a geofencing app, you can:

  • Physically move the device to new locations.
  • Test entering a geofence by creating a geofence region that includes your current physical location, so you're already inside the geofence and the "geofence entered" event is triggered immediately.
  • On Windows, use the Microsoft Visual Studio simulator to simulate locations for the device. On Windows Phone, you can simulate locations on the Location tab in the Additional Tools window of the Windows Phone Emulator.

Testing and debugging a geofencing app running in the foreground

To test your geofencing app running the foreground:

  • Build your app in Visual Studio.
  • Launch your app in the Visual Studio simulator or the Windows Phone Emulator.
  • Use these tools to simulate various locations inside and outside of your geofence region. Be sure to wait long enough past the time specified by the DwellTime property to trigger the event. Note that, on Windows, you must accept the prompt to enable location permissions for the app. For more info about simulating locations, see Set the simulated geolocation of the device.
  • You can also use the Windows Phone Emulator to estimate the size of fences and dwell times approximately needed to be detected at different speeds.

Testing and debugging a geofencing app running in the background

To test your geofencing app running the background:

  • Build your app in Visual Studio. Note that your app should set the Location background task type and, on Windows, you must set the badge or badge and tile assets for the lock screen.
  • Deploy the app locally first and, on Windows, add the app to the lock screen. You can do this by accepting the prompt to add the app to the lock screen or by manually adding the app to the lock screen in Settings. This is not required for Windows Phone apps.
  • Close your app that is running locally.
  • Launch your app in the Visual Studio simulator or the Windows Phone Emulator. Note that background geofencing simulation is supported on only one app at a time within the simulator. Do not launch multiple geofencing apps within the simulator.
  • From the simulator, simulate various locations inside and outside of your geofence region. Be sure to wait long enough past the DwellTime to trigger the event. Note that, on Windows, you must accept the prompt to enable location permissions for the app. For more info about simulating locations, see Set the simulated geolocation of the device.
  • Use Visual Studio to trigger the location background task. For more info about triggering background tasks in Visual Studio, see How to trigger background tasks.

Related topics

Roadmaps
Roadmap for Windows Store apps using C# and Visual Basic
Roadmap for Windows Store apps using C++
Designing UX for apps
Tasks
Quickstart: Setting up a geofence
Quickstart: Handling geofence notifications in the foreground
Quickstart: Listening for geofence events in the background
Quickstart: Handling geofence notifications from a background task
Reference
Geoshape
Geofence
Geolocator

 

 

Show:
© 2014 Microsoft. All rights reserved.