A geofence is a virtual area around a geographical point. The geofencing APIs enable applications to provide geographically contextual experiences in a timely manner without the need for the app to be continuously running and consuming device resources. Geofencing enables scenarios like popping up a reminder for a user when they are leaving work or home or displaying coupons when the user gets within range of a store.
Apps define areas of interest (geofences) and corresponding trigger conditions, such as triggering when the user enters or exits the geofence. Finally, the app registers to be notified when the trigger conditions are met. Windows and Windows Phone support hundreds of geofences per app. The operating system efficiently manages geofence tracking for all apps. When the trigger conditions for one or more geofences are met, the associated app is alerted even when it is not actively running. This high capacity, power-aware, adaptive geofence tracking system allows you to quickly and easily add location-triggered functionality to your app.
For a complete guide on using geofencing, see Geofencing, start to finish.
The geofencing APIs enable your app to do the following:
- Create one or more geofences, or areas of interest.
- Request to be notified when the device enters a geofence.
- Request to be notified when the device leaves a geofence.
- Specify a time window during which the geofence is active.
- Specify a dwell time for each geofence - the amount of time that the device should be in or out of the geofence before the notification is triggered.
- Dynamically add and remove a geofences from your app's collection of monitored geofences.
- Receive geofence events while the app is active.
- Register with the system to to have a background task launch when the state of one of your app's geofences changes. An app must be declared as a lock screen app in its manifest to have its background task launched by the geofencing service. On a Windows, the app must also be currently pinned to the lock screen. On phone, the geofence background task will be launched even if the app isn't currently pinned to the lock screen, but the app must still call RequestAccessAsync before any background tasks will run. For more information, see Lock Screen Overview.
- Use simulator to simulate device movement and test your app's geofencing features.
If you want your app to be launched in the background when the trigger condition for one of its geofences is met, you need to use a background task and set up a LocationTrigger to launch it.
The Windows.Devices.Geolocation.Geofencing namespace has these types of members:
The Windows.Devices.Geolocation.Geofencing namespace has these classes.
|Geofence||Contains the information to define a geofence, an area of interest, to monitor.|
|GeofenceMonitor||Contains the information about the monitored Geofence objects.|
|GeofenceStateChangeReport||Contains the information about the state changes for a Geofence.|
The Windows.Devices.Geolocation.Geofencing namespace has these enumerations.
|GeofenceMonitorStatus||Indicates the current state of a GeofenceMonitor.|
|GeofenceRemovalReason||Indicates the reason a Geofence was removed.|
|GeofenceState||Indicates the current state of a Geofence.|
|MonitoredGeofenceStates||Indicates the state or states of the Geofences that are currently being monitored by the system.|
The Windows Location Provider or the Windows Phone Location Service must be running in order for geofencing to work. If this service is disabled, geofencing calls will fail and throw an exception.
Your app must declare the location capability in the app manifest in order to use geofencing.
Minimum supported client
Minimum supported server
Minimum supported phone
|Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]|