共用方式為


Test and debug geofencing apps (XAML)

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.
  • Use the Microsoft Visual Studio emulator to simulate locations for the device.

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 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 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 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.
  • Deploy the app locally first.
  • Close your app that is running locally.
  • Launch your app in the Visual Studio emulator. Note that background geofencing simulation is supported on only one app at a time within the emulator. Do not launch multiple geofencing apps within the emulator.
  • From the emulator, 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 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.

Roadmaps

Windows 10 geolocation sample

Windows 8.1 geolocation sample

Roadmap for apps using C# and Visual Basic

Roadmap for apps using C++

Designing UX for apps

Reference

Geoshape

Geofence

Geolocator