> For the complete documentation index, see [llms.txt](https://dev.pointr.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev.pointr.tech/v9/features/geofencing/acting-on-geofence-events.md).

# Acting on Geofence Events

To set up a Geofence reaction, the mobile application needs to listen for a Geofence Event [**after starting Pointr**](broken://pages/Y3QQxljq9ApCHrAcVwVf), and take a subsequent action as shown below:

{% tabs %}
{% tab title="iOS" %}

```swift
extension MyClass: PTRGeofenceManagerDelegate {

    func listenToGeofenceEvents() {
        Pointr.shared.geofenceManager?.addListener(self)
    }

    func onGeofenceManagerGeofenceEvent(_ event: PTRGeofenceEvent) {

        let title = event.geofence.name

        // You can add custom values to a geofence on Pointr Cloud Dashboard
        let customValue = event.geofence.extraData["customField"]

        // Check event type
        switch event.type {
        case .enter:
            // Handle enter event
            displayEnterNotification(title: title, message: customValue)
        case .exit:
            // Handle exit event
            displayExitNotification(title: title, message: customValue)
        }

        // Or check geofence type
        switch event.geofence.type {
        case .beacon:
            // Handle Beacon Geofence
        case .gps:
            // Handle GPS Geofence
        }
    }
}
```

{% endtab %}

{% tab title="Android" %}

```kotlin
Pointr.getPointr()?.geofenceManager?.addListener(object : GeofenceManager.Listener {
    override fun onGeofenceManagerGeofenceEvent(event: GeofenceEvent) {

        val title = event.geofence.name

        // You can add custom values to a geofence on Pointr Cloud Dashboard
        val customValue = event.geofence.extraData["customField"]

        // Check event type
        when(event.type){
            GeofenceEventType.Enter -> {
                // Handle enter event with custom method
                displayEnterNotification(title = title, message = customValue)
            }
            GeofenceEventType.Exit -> {
                // Handle exit event
                displayExitNotification(title = title, message = customValue)
            }
        }

        // Or check geofence type
        when (event.geofence.type) {
            GeofenceType.BEACON -> {
                // Handle Beacon Geofence
            }
            GeofenceType.GPS -> {
                // Handle GPS Geofence
            }
        }
    }
})
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
The SDK provides both 'Enter' and 'Exit' events, which allows you to define what to show the user in each scenario. For more information on how to tune these events, see the [Fine Tune Geofence Sensitivity](https://dev.pointr.tech/v9/features/geofencing/fine-tuning-geofence-sensitivity.md) section.
{% endhint %}

{% hint style="info" %}
For more information on how to set up a Geofence using the Pointr Cloud Dashboard, please see the [Managing Geofences in Pointr Cloud](https://dev.pointr.tech/v9/features/geofencing/managing-geofences.md) section.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://dev.pointr.tech/v9/features/geofencing/acting-on-geofence-events.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
