Skip to main content

Overview

The RadarDelegate protocol provides client-side delivery of location updates, events, and debug logs. Implementing this delegate allows you to respond to location changes and Radar events in real-time within your app.

Setting the Delegate

Set your delegate implementation after initializing the Radar SDK:
All delegate methods are optional. Implement only the methods you need for your use case.

Delegate Methods

didReceiveEvents

Called when events are generated by Radar, such as geofence entries/exits, place visits, or trip updates.
Parameters:
  • events: Array of RadarEvent objects representing the events that were generated
  • user: The updated RadarUser object, or nil if anonymous tracking is enabled
Use this method to update your UI, trigger notifications, or update your app’s state based on location events.

didUpdateLocation

Called when the user’s location is updated and successfully synced to the server.
Parameters:
  • location: The CLLocation object representing the user’s current location
  • user: The updated RadarUser object with current context and state
This method is only called for location updates that are successfully synced to the server. Use didUpdateClientLocation if you need all location updates.

didUpdateClientLocation

Called when the device’s location is updated, even if not synced to the server. Use this for more frequent location updates.
Parameters:
  • location: The CLLocation object representing the device’s location
  • stopped: A boolean indicating whether the device is considered stopped
  • source: The RadarLocationSource indicating what triggered the location update
This method provides all location updates, including those that may not be synced to the server. Use this for real-time UI updates or analytics.

didFail

Called when a Radar request fails.
Parameters:
  • status: The RadarStatus error code indicating what went wrong

didLog

Called when the SDK generates debug log messages. Useful for debugging and troubleshooting.
Parameters:
  • message: The debug log message string
Enable log messages by setting the log level: Radar.setLogLevel(.debug)

Event Types

The RadarEventType enum includes the following event types:
  • userEnteredGeofence - User entered a geofence
  • userExitedGeofence - User exited a geofence
  • userDwelledInGeofence - User dwelled in a geofence
  • userEnteredPlace - User entered a place
  • userExitedPlace - User exited a place
  • userNearbyPlaceChain - User is near a place chain
  • userEnteredRegionCountry - User entered a country
  • userExitedRegionCountry - User exited a country
  • userEnteredRegionState - User entered a state
  • userExitedRegionState - User exited a state
  • userEnteredRegionDMA - User entered a DMA
  • userExitedRegionDMA - User exited a DMA
  • userEnteredRegionPostalCode - User entered a postal code
  • userExitedRegionPostalCode - User exited a postal code
  • userStartedTrip - User started a trip
  • userUpdatedTrip - User’s trip was updated
  • userApproachingTripDestination - User is approaching trip destination
  • userArrivedAtTripDestination - User arrived at trip destination
  • userArrivedAtWrongTripDestination - User arrived at wrong destination
  • userStoppedTrip - User stopped a trip
  • userFiredTripOrders - Trip orders were fired
  • userEnteredBeacon - User entered a beacon region
  • userExitedBeacon - User exited a beacon region
  • userFailedFraud - User failed fraud verification
  • conversion - Conversion event (from Radar.logConversion())

Complete Example

Here’s a complete example of implementing RadarDelegate:

Best Practices

Keep delegate methods lightweight

Delegate methods are called on the main thread. Avoid heavy processing or blocking operations.

Handle all error cases

Implement didFail to gracefully handle errors like permission denials or network issues.

Use appropriate callback

Use didUpdateLocation for server-synced updates, didUpdateClientLocation for all location changes.

Filter events in the delegate

Filter events by type in didReceiveEvents rather than processing all events.