> ## Documentation Index
> Fetch the complete documentation index at: https://docs.radar.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Detect geofence events and place visits

> Import your locations as geofences, turn on Places, read the user's current location context, receive entry, exit, and dwell events, send them to other systems, and log conversions.

By the end of this guide, your app will show the right experience when it opens at one of your locations, Radar will generate events as the user arrives and leaves, and your backend or messaging platform will receive them.

## Complete example

This is the client side: initialize, identify the user, request permission, start background tracking, receive events, and read current state each time the app becomes active.

```swift Swift theme={null}
import CoreLocation
import RadarSDK
import UIKit

@main
class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate, RadarDelegate {
    private let locationManager = CLLocationManager()

    func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        Radar.initialize(publishableKey: "prj_test_pk_...")
        Radar.setUserId("user-123")
        Radar.setDelegate(self)
        locationManager.delegate = self

        // Runs at launch, on resume, and after the user answers a permission prompt.
        NotificationCenter.default.addObserver(
            forName: UIApplication.didBecomeActiveNotification, object: nil, queue: .main
        ) { [weak self] _ in
            self?.refreshLocationContext()
        }
        return true
    }

    // Call after your in-app explanation: first for foreground access, and
    // again later for background access.
    func requestLocationPermission() {
        switch locationManager.authorizationStatus {
        case .notDetermined:
            locationManager.requestWhenInUseAuthorization()
        case .authorizedWhenInUse:
            locationManager.requestAlwaysAuthorization()
        default:
            break
        }
    }

    func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
        if manager.authorizationStatus == .authorizedAlways {
            Radar.startTracking(trackingOptions: .presetResponsive)
        }
    }

    // Current state. This covers a user who is already inside when the app opens.
    func refreshLocationContext() {
        Radar.trackOnce { status, location, events, user in
            guard status == .success, let user = user else {
                // No location context. Show the default experience.
                print("trackOnce failed: \(Radar.stringForStatus(status))")
                return
            }

            if let store = user.geofences?.first(where: { $0.tag == "store" }) {
                print("In store \(store.externalId ?? "")")
            } else if let place = user.place {
                print("At \(place.name)")
            } else {
                print("Not at a store or a place")
            }
        }
    }

    // Transitions, including those detected while the app is in the background.
    func didReceiveEvents(_ events: [RadarEvent], user: RadarUser?) {
        for event in events {
            switch event.type {
            case .userEnteredGeofence:
                print("Entered geofence \(event.geofence?.externalId ?? "")")
            case .userExitedGeofence:
                print("Exited geofence \(event.geofence?.externalId ?? "")")
            case .userEnteredPlace:
                print("Entered place \(event.place?.name ?? "")")
            case .userExitedPlace:
                print("Exited place \(event.place?.name ?? "")")
            default:
                break
            }
        }
    }

    func didFail(status: RadarStatus) {
        print("Radar request failed: \(Radar.stringForStatus(status))")
    }
}
```

```kotlin Kotlin theme={null}
import android.Manifest
import android.app.Application
import android.content.Context
import android.location.Location
import android.os.Build
import android.util.Log
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import io.radar.sdk.Radar
import io.radar.sdk.RadarReceiver
import io.radar.sdk.RadarTrackingOptions
import io.radar.sdk.model.RadarEvent
import io.radar.sdk.model.RadarUser

class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        Radar.initialize(this, "prj_test_pk_...")
        Radar.setUserId("user-123")
        Radar.setReceiver(AppRadarReceiver())
    }
}

class MainActivity : AppCompatActivity() {
    private val foregroundRequest = registerForActivityResult(
        ActivityResultContracts.RequestMultiplePermissions()
    ) { grants ->
        if (grants.values.any { it }) refreshLocationContext()
    }

    private val backgroundRequest = registerForActivityResult(
        ActivityResultContracts.RequestPermission()
    ) { granted ->
        if (granted) Radar.startTracking(RadarTrackingOptions.RESPONSIVE)
    }

    // Call after your in-app explanation of the foreground feature.
    fun requestForeground() {
        foregroundRequest.launch(
            arrayOf(
                Manifest.permission.ACCESS_FINE_LOCATION,
                Manifest.permission.ACCESS_COARSE_LOCATION
            )
        )
    }

    // Call later, after foreground access is granted and you have explained
    // the background feature.
    fun requestBackground() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
            backgroundRequest.launch(Manifest.permission.ACCESS_BACKGROUND_LOCATION)
        } else {
            Radar.startTracking(RadarTrackingOptions.RESPONSIVE)
        }
    }

    override fun onStart() {
        super.onStart()
        refreshLocationContext()
    }

    // Current state. This covers a user who is already inside when the app opens.
    private fun refreshLocationContext() {
        Radar.trackOnce { status, location, events, user ->
            if (status != Radar.RadarStatus.SUCCESS || user == null) {
                // No location context. Show the default experience.
                Log.w("Radar", "trackOnce failed: $status")
                return@trackOnce
            }

            val store = user.geofences?.firstOrNull { it.tag == "store" }
            val place = user.place
            when {
                store != null -> Log.d("Radar", "In store ${store.externalId}")
                place != null -> Log.d("Radar", "At ${place.name}")
                else -> Log.d("Radar", "Not at a store or a place")
            }
        }
    }
}

// Transitions, including those detected while the app is in the background.
class AppRadarReceiver : RadarReceiver() {
    override fun onEventsReceived(context: Context, events: Array<RadarEvent>, user: RadarUser?) {
        for (event in events) {
            when (event.type) {
                RadarEvent.RadarEventType.USER_ENTERED_GEOFENCE ->
                    Log.d("Radar", "Entered geofence ${event.geofence?.externalId}")
                RadarEvent.RadarEventType.USER_EXITED_GEOFENCE ->
                    Log.d("Radar", "Exited geofence ${event.geofence?.externalId}")
                RadarEvent.RadarEventType.USER_ENTERED_PLACE ->
                    Log.d("Radar", "Entered place ${event.place?.name}")
                RadarEvent.RadarEventType.USER_EXITED_PLACE ->
                    Log.d("Radar", "Exited place ${event.place?.name}")
                else -> Unit
            }
        }
    }

    override fun onError(context: Context, status: Radar.RadarStatus) {
        Log.w("Radar", "Radar request failed: $status")
    }

    override fun onLocationUpdated(context: Context, location: Location, user: RadarUser) {}

    override fun onClientLocationUpdated(
        context: Context,
        location: Location,
        stopped: Boolean,
        source: Radar.RadarLocationSource
    ) {}

    override fun onLog(context: Context, message: String) {}
}
```

```javascript React Native theme={null}
import { AppState } from 'react-native';
import Radar from 'react-native-radar';

// Module scope, so that this also runs when the app is launched in the background.
Radar.initialize('prj_test_pk_...');
Radar.setUserId('user-123');

// Transitions, including those detected while the app is in the background.
Radar.onEventsReceived(({ events }) => {
  for (const event of events) {
    switch (event.type) {
      case 'user.entered_geofence':
        console.log(`Entered geofence ${event.geofence?.externalId}`);
        break;
      case 'user.exited_geofence':
        console.log(`Exited geofence ${event.geofence?.externalId}`);
        break;
      case 'user.entered_place':
        console.log(`Entered place ${event.place?.name}`);
        break;
      case 'user.exited_place':
        console.log(`Exited place ${event.place?.name}`);
        break;
    }
  }
});

Radar.onError((status) => {
  console.warn('Radar request failed', status);
});

// Call after your in-app explanation of the foreground feature.
export async function requestForeground() {
  const status = await Radar.requestPermissions(false);
  if (status === 'GRANTED_FOREGROUND' || status === 'GRANTED_BACKGROUND') {
    await refreshLocationContext();
  }
}

// Call later, after foreground access is granted and you have explained
// the background feature.
export async function requestBackground() {
  const status = await Radar.requestPermissions(true);
  if (status === 'GRANTED_BACKGROUND') {
    Radar.startTrackingResponsive();
  }
}

// Current state. This covers a user who is already inside when the app opens.
export async function refreshLocationContext() {
  try {
    const { user } = await Radar.trackOnce();
    const store = user?.geofences?.find((geofence) => geofence.tag === 'store');
    if (store) {
      console.log(`In store ${store.externalId}`);
    } else if (user?.place) {
      console.log(`At ${user.place.name}`);
    } else {
      console.log('Not at a store or a place');
    }
  } catch (err) {
    // No location context. Show the default experience.
    console.warn('trackOnce failed', err.code);
  }
}

refreshLocationContext();
AppState.addEventListener('change', (state) => {
  if (state === 'active') refreshLocationContext();
});
```

```dart Flutter theme={null}
import 'package:flutter/widgets.dart';
import 'package:flutter_radar/flutter_radar.dart';

// Call from main(), after WidgetsFlutterBinding.ensureInitialized().
Future<void> setUpRadar() async {
  await Radar.initialize('prj_test_pk_...');
  await Radar.setUserId('user-123');
  Radar.onEvents(onEvents);
  Radar.onError((res) => debugPrint('Radar request failed: ${res['status']}'));
  WidgetsBinding.instance.addObserver(_ResumeObserver());
  await refreshLocationContext();
}

// Transitions, delivered while the Flutter engine is running.
void onEvents(Map res) {
  for (final event in (res['events'] as List?) ?? []) {
    switch (event['type']) {
      case 'user.entered_geofence':
        debugPrint('Entered geofence ${event['geofence']?['externalId']}');
        break;
      case 'user.exited_geofence':
        debugPrint('Exited geofence ${event['geofence']?['externalId']}');
        break;
      case 'user.entered_place':
        debugPrint('Entered place ${event['place']?['name']}');
        break;
      case 'user.exited_place':
        debugPrint('Exited place ${event['place']?['name']}');
        break;
    }
  }
}

// Call after your in-app explanation of the foreground feature.
Future<void> requestForeground() async {
  await Radar.requestPermissions(false);
  final status = await Radar.getPermissionsStatus();
  if (status == 'GRANTED_FOREGROUND' || status == 'GRANTED_BACKGROUND') {
    await refreshLocationContext();
  }
}

// Call later, after foreground access is granted and you have explained
// the background feature.
Future<void> requestBackground() async {
  await Radar.requestPermissions(true);
  if (await Radar.getPermissionsStatus() == 'GRANTED_BACKGROUND') {
    await Radar.startTracking('responsive');
  }
}

// Current state. This covers a user who is already inside when the app opens.
Future<void> refreshLocationContext() async {
  final res = await Radar.trackOnce();
  if (res?['status'] != 'SUCCESS') {
    // No location context. Show the default experience.
    debugPrint('trackOnce failed: ${res?['status'] ?? res?['error']}');
    return;
  }

  final user = res?['user'];
  final geofences = (user?['geofences'] as List?) ?? [];
  final stores = geofences.where((geofence) => geofence['tag'] == 'store');
  if (stores.isNotEmpty) {
    debugPrint('In store ${stores.first['externalId']}');
  } else if (user?['place'] != null) {
    debugPrint('At ${user['place']['name']}');
  } else {
    debugPrint('Not at a store or a place');
  }
}

class _ResumeObserver with WidgetsBindingObserver {
  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    if (state == AppLifecycleState.resumed) refreshLocationContext();
  }
}
```

The web SDK has no background tracking. On the web, read current state as in [Show an on-premise experience](#show-an-on-premise-experience). Your backend receives each event in this shape:

```json theme={null}
{
  "event": {
    "_id": "64f0a1b2c3d4e5f6a7b8c9e0",
    "type": "user.entered_geofence",
    "createdAt": "2026-03-02T17:04:10.535Z",
    "actualCreatedAt": "2026-03-02T17:04:11.102Z",
    "live": false,
    "confidence": 3,
    "foreground": false,
    "geofence": {
      "tag": "store",
      "externalId": "store-42",
      "description": "Store 42",
      "metadata": {
        "curbside": true
      }
    },
    "location": {
      "type": "Point",
      "coordinates": [-73.975363, 40.783826]
    },
    "locationAccuracy": 12
  },
  "user": {
    "_id": "64f0a1b2c3d4e5f6a7b8c9d0",
    "userId": "user-123",
    "live": false
  }
}
```

## Prerequisites

* A Radar project and its Test publishable key. See [Choose the right API key](https://docs.radar.com/fundamentals/authentication-and-access.md#choose-the-right-api-key).
* The Radar SDK for [iOS](https://docs.radar.com/sdk/ios.md), [Android](https://docs.radar.com/sdk/android.md), [web](https://docs.radar.com/sdk/web.md), [React Native](https://docs.radar.com/sdk/react-native.md), or [Flutter](https://docs.radar.com/sdk/flutter.md). On iOS and Android, initialize it in `AppDelegate` or `Application.onCreate()`, because the operating system can launch your app in the background.
* A stable user ID for `Radar.setUserId()`. See [Handle login, logout, and user switching](https://docs.radar.com/fundamentals/authentication-and-access.md#handle-login-logout-and-user-switching).

## Create geofences

A geofence is identified by its `tag` (a group you choose, such as `store`) and its `externalId` (your ID for the location, such as `store-42`). Every import path upserts on that pair, so to change a location, send it again. Geofences live in one environment: import into Test while you build, then into Live.

To create a few geofences by hand, open the [Geofences](https://dashboard.radar.com/geofencing/geofences) page and click **Create**. For "near the store" messages, add a second, larger geofence with the same `externalId` and a different tag, such as `nearby`. Put per-location flags, such as `"curbside": true`, in `metadata`, which Radar returns with every event.

### CSV import

On the Geofences page, click **Import** and select a CSV file with a header row. The [import history](https://dashboard.radar.com/geofencing/geofences/imports) page shows the error for each row that failed.

| Column | Description |
| - | - |
| `description` | A display name, such as `Store 42`. |
| `tag` | A group, such as `store`. |
| `externalId` | Your ID for the location. Unique within the tag. |
| `type` | `circle`, `polygon`, or `isochrone`. |
| `coordinates` | The center as `[longitude,latitude]`, or a closed ring of points for a `polygon`. Required unless `address` is set. |
| `address` | An address for Radar to geocode as the center. Required unless `coordinates` is set. |
| `radius` | For `circle`, the radius in meters, from `10` to `10000`. |

Optional columns, such as `enabled`, `metadata`, `operatingHours`, `stopDetection`, and `dwellThreshold`, match the body parameters of [Upsert a geofence](https://docs.radar.com/api/geofences.md#upsert-a-geofence). In a CSV, `metadata` is a JSON string.

> [!NOTE]
>
> Longitude comes before latitude in `coordinates`. A swapped pair imports without errors but puts the geofence in the wrong place.

This example imports two circles, a polygon, and a store located by address:

```text theme={null}
description,tag,externalId,type,radius,coordinates,address,enabled,metadata
"Store 42",store,store-42,circle,100,"[-73.975363,40.783826]",,true,"{""curbside"":true}"
"Near Store 42",nearby,store-42,circle,1000,"[-73.975363,40.783826]",,true,"{""curbside"":true}"
"Example neighborhood",neighborhood,example-1,polygon,,"[[-73.996973,40.725660],[-74.001072,40.727660],[-74.004998,40.723530],[-73.999827,40.718016],[-73.996973,40.725660]]",,true,
"Store 43",store,store-43,circle,100,,"20 Jay St, Brooklyn, NY 11201",true,
```

### API

Call the upsert endpoint from your backend, with a secret key, when a location is created, changed, or closed.

```bash theme={null}
curl "https://api.radar.io/v1/geofences/store/store-42" \
  -X PUT \
  -H "Authorization: prj_test_sk_..." \
  -d "description=Store 42" \
  -d "type=circle" \
  -d "coordinates=[-73.975363,40.783826]" \
  -d "radius=100"
```

To stop a closed location from generating events without deleting it, send `enabled=false`. For every field, see the [Geofences API](https://docs.radar.com/api/geofences.md).

### Geofence sync

Geofence sync reads a CSV with the same columns from a location you control and upserts its rows once a night.

1. On the [Integrations](https://dashboard.radar.com/integrations) page, find **Geofence Sync** and set **Enabled** to **Yes**.
2. Enter a **Notification Email** for the result of each sync.
3. Select a **Protocol**: **HTTP** for a CSV at a public URL, or **AWS S3** for a private bucket, with the access key of an IAM user that has `GetObject` permission.
4. Enter a file for Test, for Live, or for both, and click **Save and Sync**. Radar syncs once immediately, then nightly.

> [!NOTE]
>
> Sync and import both upsert. Rows missing from the file aren't deleted.

To retire a location, keep its row and set `enabled` to `false`, or delete the geofence.

## Enable Places

Places detects visits to places in Radar's dataset by chain (such as `starbucks`) and category (such as `airport`), with no geofence for each one. In the **Places** section of the [Settings](https://dashboard.radar.com/settings) page, turn on `user.entered_place` and `user.exited_place` under **Event types**, add [chain](https://docs.radar.com/places/chains) slugs under **Chains** and [categories](https://docs.radar.com/places/categories) under **Categories**, and save.

`user.place` is a single place, so branch on `place.chain.slug` or a category. Place matching, which must be enabled for your project, links a geofence to a Radar place through `placeId`, so that a circle takes the place's center and shape.

## Request permissions and start tracking

Foreground permission is enough for `Radar.trackOnce()` on open and resume. Events while the app is closed need background permission and `Radar.startTracking()` with the responsive preset, called only after background access is granted. See [Understand foreground and background location permissions](https://docs.radar.com/fundamentals/location-permissions.md) and [Tracking options](https://docs.radar.com/sdk/tracking.md).

On iOS, the responsive preset needs the **Location updates** and **Background fetch** background modes. Don't use the continuous preset for geofence detection. It is meant for [trips](https://docs.radar.com/geofencing/trips.md), and on Android it runs a foreground service, which Google Play doesn't accept for geofencing alone.

## Receive events in the app

`trackOnce()` returns the events generated by that one update. To receive every event, including those generated in the background, register a delegate on iOS or a receiver on Android at app startup. In Flutter, the listener runs only while the Flutter engine is running.

| Event | When it fires |
| - | - |
| `user.entered_geofence` | The first location update inside a geofence the user wasn't already in. The user must exit before Radar generates another entry for the same geofence. |
| `user.exited_geofence` | The first update outside a geofence the user was in. `duration` is the minutes between entry and exit. |
| `user.dwelled_in_geofence` | The first update after the user has stayed longer than the geofence's `dwellThreshold`, in minutes. |
| `user.entered_place` | The user stops at a place that matches your chain and category filters. Passing by doesn't count. |
| `user.exited_place` | The user leaves that place. |

Turn geofence event types on or off in the **Geofences** section of the Settings page. To drop entries from users who pass by, turn on **Geofence stop detection** in the same section, so that only a stop in the geofence generates an entry, or ignore events whose `confidence` is below `3` (high).

Radar generates an event when the location update that crosses the boundary arrives: immediately in the foreground, and within the preset's update interval in the background, or later when the operating system delays updates. Check `createdAt`, the time the location was recorded on the device, before a time-sensitive action.

## Show an on-premise experience

Drive anything the app shows only while the user is at a location, such as a store mode, from current state. Call `Radar.trackOnce()` each time the app opens or returns to the foreground and read `user.geofences` and `user.place`. This covers a user who is already inside when the app opens, when Radar generates no new entry event.

When a later check returns no matching geofence, or the call fails, return to the default experience. Don't wait for an exit event. On the web, the same check reads a per-location flag from geofence metadata:

```javascript JavaScript theme={null}
import Radar from 'radar-sdk-js';

// Call on page load and when the tab becomes visible again.
async function refreshStoreMode() {
  try {
    const { user } = await Radar.trackOnce();
    const store = user?.geofences?.find((geofence) => geofence.tag === 'store');
    if (store) {
      return { mode: 'inStore', storeId: store.externalId, curbside: store.metadata?.curbside === true };
    }
    if (user?.place?.chain?.slug) {
      return { mode: 'atPlace', chainSlug: user.place.chain.slug };
    }
  } catch (err) {
    // Fall through to the default experience.
  }
  return { mode: 'none' };
}
```

## Send location-triggered messages

Radar sends events and user attributes server-to-server, so the system that sends the message knows who (`user.userId`), what (`event.type`), and where (the geofence `tag`, `externalId`, and `metadata`, or `place.chain.slug`). Turn on a native integration, such as [Braze](https://docs.radar.com/integrations/braze.md), or create a webhook to an HTTPS endpoint you control when your backend decides what to send. A webhook handler verifies the request, returns `2xx` quickly, and deduplicates on `event._id`. See [Integrations](https://docs.radar.com/integrations/integrations.md) and [Webhooks](https://docs.radar.com/integrations/webhooks.md). The ID you pass to `Radar.setUserId()` must match the messaging platform's ID for the same person.

### Use Radar campaigns

Radar can also send the notification or in-app message itself, from campaigns you create on the [Campaigns](https://dashboard.radar.com/geofencing/campaigns) page. The SDK shows an event-based notification as a local notification, so it needs notification permission and no push credentials. To attribute app opens to a campaign on iOS, set `autoLogNotificationConversions` in the [initialization options](https://docs.radar.com/sdk/ios.md#initialization-options). For React Native or Expo, see [Set up campaign notifications](https://docs.radar.com/sdk/react-native.md#set-up-campaign-notifications). For campaign types, targeting, scheduling, and frequency capping, see [Campaigns](https://docs.radar.com/geofencing/campaigns).

## Log conversions

A conversion records a business action, such as an order, together with where the user was.

```swift Swift theme={null}
import RadarSDK

// With revenue and metadata
Radar.logConversion(
    name: "order_placed",
    revenue: NSNumber(value: 24.50),
    metadata: ["orderId": "order-1001", "fulfillment": "pickup"]
) { status, event in
    if status != .success {
        print("logConversion failed: \(Radar.stringForStatus(status))")
    }
}

// Without revenue
Radar.logConversion(name: "sign_up", metadata: nil) { status, event in }
```

```kotlin Kotlin theme={null}
import android.util.Log
import io.radar.sdk.Radar
import org.json.JSONObject

// With revenue and metadata
val metadata = JSONObject()
    .put("orderId", "order-1001")
    .put("fulfillment", "pickup")

Radar.logConversion("order_placed", 24.50, metadata) { status, event ->
    if (status != Radar.RadarStatus.SUCCESS) {
        Log.w("Radar", "logConversion failed: $status")
    }
}

// Without revenue
Radar.logConversion("sign_up", null) { status, event -> }
```

```javascript JavaScript theme={null}
import Radar from 'radar-sdk-js';

await Radar.logConversion({
  name: 'order_placed',
  revenue: 24.5,
  metadata: { orderId: 'order-1001', fulfillment: 'pickup' },
});
```

```javascript React Native theme={null}
import Radar from 'react-native-radar';

await Radar.logConversion({
  name: 'order_placed',
  revenue: 24.5,
  metadata: { orderId: 'order-1001', fulfillment: 'pickup' },
});
```

`revenue` and `metadata` are optional. Radar attaches the geofences, place, and regions from the user's latest location update, and the conversion appears on the [Events](https://dashboard.radar.com/geofencing/events) page. To log one from your backend, see [Log a conversion](https://docs.radar.com/api/events.md#log-a-conversion).

## Handle results and errors

| Result | Meaning | What to do |
| - | - | - |
| `ERROR_PERMISSIONS` | Location permission is denied. | Show the default experience and a manual location choice. Don't prompt again on every launch. |
| `ERROR_LOCATION` or `ERROR_NETWORK` | No location fix, or no network. | Show the default experience and retry on the next foreground. |
| A publishable key or unauthorized status | The key is wrong or missing. | Check that the build uses the key for the intended environment. |
| Success with empty `geofences` on site | No geofence matched. | Check the environment, that the geofence is enabled, and the location accuracy against the geofence size. |
| No events while the app is closed | Background tracking isn't running. | Confirm background permission, `Radar.isTracking()`, and the iOS background modes. After a force-quit, updates resume when the user opens the app. |

## Test the integration

* **Passing case**: Stand inside a Test geofence, or simulate a location inside it on the [Simulator](https://dashboard.radar.com/geofencing/simulate) page, and cold-start the app. The on-premise experience appears, and `user.entered_geofence` reaches your webhook.
* **Failing case**: Deny location permission and open the app. The default experience appears, with no repeated prompt.

See [Test, troubleshoot, and go live](https://docs.radar.com/fundamentals/testing-and-launch.md).

## Production checklist

* [ ] Release builds use the Live publishable key, and the secret key exists only on your backend.
* [ ] Geofences, Places, event types, and integrations are set up in Live, and a sync or API update keeps geofences current.
* [ ] Tracking starts only after background permission is granted, with the responsive or efficient preset.
* [ ] The webhook handler verifies requests and deduplicates on `event._id`.

## Build with an agent

Copy this prompt into a coding agent that has access to your repository.

```text theme={null}
Implement Radar geofence and place detection in this repository.
Read https://docs.radar.com/geofencing/geofences-and-places.md, the SDK
reference for this app's platform (https://docs.radar.com/sdk/ios.md or
https://docs.radar.com/sdk/android.md), and
https://docs.radar.com/fundamentals/location-permissions.md.
Constraints: read user.geofences and user.place from Radar.trackOnce() on app
open and resume instead of waiting for an entry event. Start tracking with the
responsive preset only after background permission is granted. Never put a
secret key in client code. Do not invent methods, fields, or event names.
Add tests for: opening inside a geofence, opening outside any geofence, a
permissions error from trackOnce, and entry and exit events reaching the handler.
Report changed files, test results, and the dashboard setup I still need to do.
```

## See also

* [Geofences API](https://docs.radar.com/api/geofences.md) and [Events API](https://docs.radar.com/api/events.md)
* [Understand geofences, places, regions, beacons, and fraud context](https://docs.radar.com/fundamentals/context-types.md), for regions and user insights
* [Track pickups, deliveries, and workers](https://docs.radar.com/geofencing/trips.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.