Polyfence documentation

Create geofence zones via the dashboard or API. Mobile SDKs sync zones to devices and detect enter/exit events on-device — no GPS data leaves the phone.

Quickstart

Pick your platform. Install, add a zone, start detecting.

Install the plugin:

$ flutter pub add polyfence

Initialize, add a zone, start tracking:

import 'package:polyfence/polyfence.dart';

await Polyfence.instance.initialize();

final zone = Zone.circle(
  id: 'office',
  name: 'London Office',
  center: PolyfenceLocation(51.5074, -0.1278),
  radius: 200,
);

await Polyfence.instance.addZone(zone);
await Polyfence.instance.startTracking();

// Listen for enter/exit events
Polyfence.instance.geofenceEvents.listen((event) {
  print('${event.type} zone: ${event.zone.name}');
});

How it works

1
You define zones

Draw circles and polygons on the map, import GeoJSON, or create zones via the REST API.

2
SDKs sync zones to devices

Mobile SDKs download zone data automatically. Works offline once synced. No manual sync code needed.

3
Devices detect enter/exit locally

Geofence events fire on-device using the native Kotlin/Swift engine. No cloud calls at runtime. Your app handles events however you want.

API reference

Server SDKs & CLI

CLI

npm i -g @polyfence/cli — list, create, export zones from the terminal. CI/CD and batch operations.

Key concepts

Zones
A geographic area (circle or polygon) that triggers events when a device enters or exits. Create via the dashboard, import as GeoJSON, or use the API. No limit on zone count during early access.
On-device detection
All geofencing runs on the user's phone using the native Kotlin/Swift engine (polyfence-core). No location data is sent to any server. Events fire locally and your app decides what to do with them.
SmartGPS
The SDK adapts GPS polling based on user activity (walking, driving, stationary) and proximity to zones. Saves battery while keeping detection accuracy under 50ms.
API keys
Authenticate REST API calls with an x-api-key header. Keys are scoped ( zones:read, zones:write, zones:delete ) and stored as SHA-256 hashes.
Get API key

Platform support

iOS 14.0+Android API 24+Flutter SDK 3.10+React Native 0.71+MIT LicensePrivacy: on-device by default