Skip to main content

Overview

The Radar class is the primary interface for the Radar iOS SDK. It provides methods for:
  • SDK initialization and configuration
  • User identification and metadata management
  • Location tracking (foreground and background)
  • Trip tracking and management
  • Search (places, geofences)
  • Geocoding and reverse geocoding
  • Distance and routing calculations
  • Event handling and conversions

Initialization

isInitialized

Returns whether the SDK has been initialized.

initialize(publishableKey:)

Initializes the Radar SDK.
Call this method from the main thread in your AppDelegate class before calling any other Radar methods.
String
required
Your publishable API key.

initialize(publishableKey:options:)

Initializes the Radar SDK with additional configuration options.
Call this method from the main thread in your AppDelegate class before calling any other Radar methods.
String
required
Your publishable API key.
RadarInitializeOptions
Radar SDK initialization options.

Properties

sdkVersion

Gets the version number of the Radar SDK, such as “3.5.1” or “3.5.1-beta.2”.

User Identification

setUserId(_:)

Identifies the user.
Until you identify the user, Radar will automatically identify the user by deviceId (IDFV).
String
A stable unique ID for the user. If nil, the previous userId will be cleared.

getUserId()

Returns the current userId.

setDescription(_:)

Sets an optional description for the user, displayed in the dashboard.
String
A description for the user. If nil, the previous description will be cleared.

getDescription()

Returns the current description.

setMetadata(_:)

Sets an optional set of custom key-value pairs for the user.
Dictionary
A set of custom key-value pairs for the user. Must have 16 or fewer keys and values of type string, boolean, or number. If nil, the previous metadata will be cleared.

getMetadata()

Returns the current metadata.

Tags

getTags()

Returns the current tags.

setTags(_:)

Sets tags, replacing any existing tags.
Array<String>
An array of tags. If nil, all tags will be cleared.

addTags(_:)

Adds tags to the existing set.
Array<String>
required
An array of tags to add.

removeTags(_:)

Removes tags from the existing set.
Array<String>
required
An array of tags to remove.

Product

setProduct(_:)

Sets an optional product name, displayed in the dashboard and reports.
String
A product name. If nil, the previous product will be cleared.

getProduct()

Returns the current product.

Privacy

setAnonymousTrackingEnabled(_:)

Enables anonymous tracking for privacy reasons. Avoids creating user records on the server and avoids sending any stable device IDs, user IDs, and user metadata to the server when calling trackOnce() or startTracking(). Disabled by default.
Bool
required
A boolean indicating whether anonymous tracking should be enabled.

Location

getLocation(completionHandler:)

Gets the device’s current location.
RadarLocationCompletionHandler
An optional completion handler called when the request succeeds, fails, or times out.
  • status: The request status
  • location: The device’s location, if successful
  • stopped: Whether the device is stopped

getLocation(desiredAccuracy:completionHandler:)

Gets the device’s current location with the desired accuracy.
RadarTrackingOptionsDesiredAccuracy
required
The desired accuracy (.high, .medium, or .low).
RadarLocationCompletionHandler
An optional completion handler.

Foreground Tracking

trackOnce(completionHandler:)

Tracks the user’s location once in the foreground.
Note that these calls are subject to rate limits.
RadarTrackCompletionHandler
An optional completion handler called when the request succeeds, fails, or times out.
  • status: The request status
  • location: The user’s location, if successful
  • events: An array of events generated, if any
  • user: The user, if successful

trackOnce(desiredAccuracy:beacons:completionHandler:)

Tracks the user’s location once with the desired accuracy and optionally ranges beacons in the foreground.
Note that these calls are subject to rate limits.
RadarTrackingOptionsDesiredAccuracy
required
The desired accuracy.
Bool
required
A boolean indicating whether to range beacons.
RadarTrackCompletionHandler
An optional completion handler.

trackOnce(location:completionHandler:)

Manually updates the user’s location.
Note that these calls are subject to rate limits.
CLLocation
required
A location for the user.
RadarTrackCompletionHandler
An optional completion handler.

Verified Tracking

trackVerified(completionHandler:)

Tracks the user’s location with device integrity information for location verification use cases.
Note that you must configure SSL pinning before calling this method.
RadarTrackVerifiedCompletionHandler
An optional completion handler called when the request succeeds, fails, or times out.
  • status: The request status
  • token: The verified location token, if successful. Verify the token server-side using your secret key.

trackVerified(beacons:desiredAccuracy:completionHandler:)

Tracks the user’s location with device integrity information for location verification use cases.
Note that you must configure SSL pinning before calling this method.
Bool
required
A boolean indicating whether to range beacons.
RadarTrackingOptionsDesiredAccuracy
required
The desired accuracy.
RadarTrackVerifiedCompletionHandler
An optional completion handler.

trackVerified(beacons:desiredAccuracy:reason:transactionId:completionHandler:)

Tracks the user’s location with device integrity information for location verification use cases.
Note that you must configure SSL pinning before calling this method.
Bool
required
A boolean indicating whether to range beacons.
RadarTrackingOptionsDesiredAccuracy
required
The desired accuracy.
String
An optional reason, displayed in the dashboard and reports.
String
An optional transaction ID, displayed in the dashboard and reports.
RadarTrackVerifiedCompletionHandler
An optional completion handler.

startTrackingVerified(interval:beacons:)

Starts tracking the user’s location with device integrity information for location verification use cases.
Note that you must configure SSL pinning before calling this method.
TimeInterval
required
The default interval in seconds between each location update.
Bool
required
A boolean indicating whether to range beacons.

stopTrackingVerified()

Stops tracking the user’s location with device integrity information for location verification use cases.

isTrackingVerified()

Returns a boolean indicating whether verified tracking has been started.

getVerifiedLocationToken(completionHandler:)

Returns the user’s last verified location token if still valid, or requests a fresh token if not.
Note that you must configure SSL pinning before calling this method.
RadarTrackVerifiedCompletionHandler
An optional completion handler.

getVerifiedLocationToken(beacons:desiredAccuracy:completionHandler:)

Returns the user’s last verified location token if still valid, or requests a fresh token if not.
Note that you must configure SSL pinning before calling this method.
Bool
required
A boolean indicating whether to range beacons.
RadarTrackingOptionsDesiredAccuracy
required
The desired accuracy.
RadarTrackVerifiedCompletionHandler
An optional completion handler.

clearVerifiedLocationToken()

Clears the user’s last verified location token.

setExpectedJurisdiction(countryCode:stateCode:)

Optionally sets the user’s expected country and state for jurisdiction checks.
String
The user’s expected two-letter country code.
String
The user’s expected two-letter state code.

Background Tracking

startTracking(trackingOptions:)

Starts tracking the user’s location in the background with configurable tracking options.
RadarTrackingOptions
required
Configurable tracking options. Use preset options like RadarTrackingOptions.presetContinuous, RadarTrackingOptions.presetResponsive, or RadarTrackingOptions.presetEfficient, or create custom options.

mockTracking(origin:destination:mode:steps:interval:completionHandler:)

Mocks tracking the user’s location from an origin to a destination.
CLLocation
required
The origin.
CLLocation
required
The destination.
RadarRouteMode
required
The travel mode.
Int
required
The number of mock location updates.
TimeInterval
required
The interval in seconds between each mock location update. A number between 1 and 60.
RadarTrackCompletionHandler
An optional completion handler.

stopTracking()

Stops tracking the user’s location in the background.

isTracking()

Returns a boolean indicating whether tracking has been started.

getTrackingOptions()

Returns the current tracking options.

isUsingRemoteTrackingOptions()

Returns a boolean indicating whether local tracking options are being overridden by remote tracking options.

Delegate

setDelegate(_:)

Sets a delegate for client-side delivery of events, location updates, and debug logs.
RadarDelegate
A delegate for client-side delivery of events, location updates, and debug logs. If nil, the previous delegate will be cleared.

setVerifiedDelegate(_:)

Sets a delegate for client-side delivery of verified location tokens.
RadarVerifiedDelegate
A delegate for client-side delivery of verified location tokens. If nil, the previous delegate will be cleared.

Events

acceptEventId(_:verifiedPlaceId:)

Accepts an event. Events can be accepted after user check-ins or other forms of verification. Event verifications will be used to improve the accuracy and confidence level of future events.
String
required
The ID of the event to accept.
String
For place entry events, the ID of the verified place. May be nil.

rejectEventId(_:)

Rejects an event. Events can be rejected after user check-ins or other forms of verification. Event verifications will be used to improve the accuracy and confidence level of future events.
String
required
The ID of the event to reject.

logConversion(name:metadata:completionHandler:)

Logs a conversion.
String
required
The name of the conversion.
Dictionary
The metadata associated with the conversion.
RadarLogConversionCompletionHandler
required
A completion handler called when the request succeeds, fails, or times out.
  • status: The request status
  • event: The conversion event generated, if successful

logConversion(name:revenue:metadata:completionHandler:)

Logs a conversion with revenue.
String
required
The name of the conversion.
NSNumber
required
The revenue generated by the conversion.
Dictionary
The metadata associated with the conversion.
RadarLogConversionCompletionHandler
required
A completion handler.

logConversion(request:)

Logs a conversion with a notification.
UNNotificationRequest
The request associated with the notification.

logConversion(response:)

Logs a conversion with a notification. This should only be used to manually setup logging of notification conversions.
UNNotificationResponse
required
The response associated with user interaction with the notification.

Trips

getTripOptions()

Returns the current trip options.

getTrip()

Returns the current trip, including legs for multi-destination trips. Use the legs’ _id values when calling updateTripLeg.

startTrip(options:)

Starts a trip.
RadarTripOptions
required
Configurable trip options.

startTrip(options:completionHandler:)

Starts a trip.
RadarTripOptions
required
Configurable trip options.
RadarTripCompletionHandler
An optional completion handler called when the request succeeds, fails, or times out.
  • status: The request status
  • trip: The trip, if successful
  • events: An array of events generated, if any

startTrip(options:trackingOptions:completionHandler:)

Starts a trip.
RadarTripOptions
required
Configurable trip options.
RadarTrackingOptions
Tracking options to use during the trip.
RadarTripCompletionHandler
An optional completion handler.

updateTrip(options:status:completionHandler:)

Manually updates a trip.
RadarTripOptions
required
Configurable trip options.
RadarTripStatus
required
The trip status. To avoid updating status, pass RadarTripStatus.unknown.
RadarTripCompletionHandler
An optional completion handler.

completeTrip()

Completes a trip.

completeTrip(completionHandler:)

Completes a trip.
RadarTripCompletionHandler
An optional completion handler.

cancelTrip()

Cancels a trip.

cancelTrip(completionHandler:)

Cancels a trip.
RadarTripCompletionHandler
An optional completion handler.

updateTripLeg(tripId:legId:status:completionHandler:)

Updates a trip leg status for multi-destination trips.
String
required
The Radar ID of the trip (from RadarTrip._id).
String
required
The Radar ID of the leg (from RadarTripLeg._id).
RadarTripLegStatus
required
The new status for the leg.
RadarTripLegCompletionHandler
An optional completion handler called when the request succeeds, fails, or times out.
  • status: The request status
  • trip: The trip, if successful
  • leg: The updated leg, if successful
  • events: An array of events generated, if any

updateTripLeg(legId:status:completionHandler:)

Updates a trip leg status for multi-destination trips, using the current trip’s ID.
String
required
The Radar ID of the leg (from RadarTripLeg._id).
RadarTripLegStatus
required
The new status for the leg.
RadarTripLegCompletionHandler
An optional completion handler.

updateCurrentTripLeg(status:completionHandler:)

Updates the current trip leg status for multi-destination trips. Uses the current trip’s ID and currentLegId automatically.
RadarTripLegStatus
required
The new status for the current leg.
RadarTripLegCompletionHandler
An optional completion handler.

reorderTripLegs(tripId:legIds:completionHandler:)

Reorders the legs of a multi-destination trip.
String
required
The Radar ID of the trip (from RadarTrip._id).
Array<String>
required
An array of leg IDs in the desired new order.
RadarTripCompletionHandler
An optional completion handler.

reorderTripLegs(legIds:completionHandler:)

Reorders the legs of the current multi-destination trip.
Array<String>
required
An array of leg IDs in the desired new order.
RadarTripCompletionHandler
An optional completion handler.

Context

getContext(completionHandler:)

Gets the device’s current location, then gets context for that location without sending device or user identifiers to the server.
RadarContextCompletionHandler
required
A completion handler called when the request succeeds, fails, or times out.
  • status: The request status
  • location: The location, if successful
  • context: The context, if successful

getContext(location:completionHandler:)

Gets context for a location without sending device or user identifiers to the server.
CLLocation
required
The location.
RadarContextCompletionHandler
required
A completion handler.

searchPlaces(radius:chains:categories:groups:countryCodes:limit:completionHandler:)

Gets the device’s current location, then searches for places near that location, sorted by distance.
You may specify only one of chains, categories, or groups.
Int
required
The radius to search, in meters. A number between 100 and 10000.
Array<String>
An array of chain slugs to filter. See Chains.
Array<String>
An array of categories to filter. See Categories.
Array<String>
An array of groups to filter. See Groups.
Array<String>
An array of country codes to filter. See Countries.
Int
required
The max number of places to return. A number between 1 and 100.
RadarSearchPlacesCompletionHandler
required
A completion handler called when the request succeeds, fails, or times out.
  • status: The request status
  • location: The location, if successful
  • places: An array of places sorted by distance, if successful

searchPlaces(radius:chains:chainMetadata:categories:groups:countryCodes:limit:completionHandler:)

Gets the device’s current location, then searches for places near that location, sorted by distance.
You may specify only one of chains, categories, or groups; if chains are specified, chainMetadata can also be specified.
Int
required
The radius to search, in meters. A number between 100 and 10000.
Array<String>
An array of chain slugs to filter.
Dictionary<String, String>
Optional chain metadata filters. Keys and values must be strings.
Array<String>
An array of categories to filter.
Array<String>
An array of groups to filter.
Array<String>
An array of country codes to filter.
Int
required
The max number of places to return. A number between 1 and 100.
RadarSearchPlacesCompletionHandler
required
A completion handler.

searchPlaces(near:radius:chains:categories:groups:countryCodes:limit:completionHandler:)

Searches for places near a location, sorted by distance.
You may specify only one of chains, categories, or groups.
CLLocation
required
The location to search.
Int
required
The radius to search, in meters. A number between 100 and 10000.
Array<String>
An array of chain slugs to filter.
Array<String>
An array of categories to filter.
Array<String>
An array of groups to filter.
Array<String>
An array of country codes to filter.
Int
required
The max number of places to return. A number between 1 and 100.
RadarSearchPlacesCompletionHandler
required
A completion handler.

searchPlaces(near:radius:chains:chainMetadata:categories:groups:countryCodes:limit:completionHandler:)

Searches for places near a location, sorted by distance.
You may specify only one of chains, categories, or groups.
CLLocation
required
The location to search.
Int
required
The radius to search, in meters. A number between 100 and 10000.
Array<String>
An array of chain slugs to filter.
Dictionary<String, String>
Optional chain metadata filters.
Array<String>
An array of categories to filter.
Array<String>
An array of groups to filter.
Array<String>
An array of country codes to filter.
Int
required
The max number of places to return. A number between 1 and 100.
RadarSearchPlacesCompletionHandler
required
A completion handler.

searchGeofences(completionHandler:)

Gets the device’s current location, then searches for geofences near that location, sorted by distance.
RadarSearchGeofencesCompletionHandler
required
A completion handler called when the request succeeds, fails, or times out.
  • status: The request status
  • location: The location, if successful
  • geofences: An array of geofences sorted by distance, if successful

searchGeofences(near:radius:tags:metadata:limit:includeGeometry:completionHandler:)

Searches for geofences near a location, sorted by distance.
CLLocation
The location to search. Use nil to search near the device’s current location.
Int
required
The radius to search, in meters. A number between 100 and 10000. If -1 is entered, the server defaults to using unlimited radius.
Array<String>
An array of tags to filter.
Dictionary
A dictionary of metadata to filter.
Int
required
The max number of geofences to return. A number between 1 and 1000. Defaults to 100.
Bool
required
Include geofence geometries in the response. Recommended to be set to false unless you specifically need the geometries. To retrieve more than 100 results, includeGeometry must be set to false.
RadarSearchGeofencesCompletionHandler
required
A completion handler.

autocomplete(query:near:layers:limit:country:mailable:completionHandler:)

Autocompletes partial addresses and place names, sorted by relevance.
String
required
The partial address or place name to autocomplete.
CLLocation
A location for the search.
Array<String>
Optional layer filters.
Int
required
The max number of addresses to return. A number between 1 and 100.
String
An optional country filter. A string, the unique 2-letter country code.
Bool
required
Whether to only include mailable addresses.
RadarGeocodeCompletionHandler
required
A completion handler called when the request succeeds, fails, or times out.
  • status: The request status
  • addresses: The geocoding results (an array of addresses), if successful

autocomplete(query:near:layers:limit:country:completionHandler:)

Autocompletes partial addresses and place names, sorted by relevance.
String
required
The partial address or place name to autocomplete.
CLLocation
A location for the search.
Array<String>
Optional layer filters.
Int
required
The max number of addresses to return. A number between 1 and 100.
String
An optional country filter.
RadarGeocodeCompletionHandler
required
A completion handler.

autocomplete(query:near:limit:completionHandler:)

Autocompletes partial addresses and place names, sorted by relevance.
String
required
The partial address or place name to autocomplete.
CLLocation
A location for the search.
Int
required
The max number of addresses to return. A number between 1 and 100.
RadarGeocodeCompletionHandler
required
A completion handler.

Geocoding

geocode(address:completionHandler:)

Geocodes an address, converting address to coordinates.
String
required
The address to geocode.
RadarGeocodeCompletionHandler
required
A completion handler.

geocode(address:layers:countries:completionHandler:)

Geocodes an address, converting address to coordinates.
String
required
The address to geocode.
Array<String>
Optional layer filters.
Array<String>
Optional country filters. A string array of unique 2-letter country codes.
RadarGeocodeCompletionHandler
required
A completion handler.

reverseGeocode(completionHandler:)

Gets the device’s current location, then reverse geocodes that location, converting coordinates to address.
RadarGeocodeCompletionHandler
required
A completion handler.

reverseGeocode(layers:completionHandler:)

Gets the device’s current location, then reverse geocodes that location, converting coordinates to address.
Array<String>
Optional layer filters.
RadarGeocodeCompletionHandler
required
A completion handler.

reverseGeocode(location:completionHandler:)

Reverse geocodes a location, converting coordinates to address.
CLLocation
required
The location to reverse geocode.
RadarGeocodeCompletionHandler
required
A completion handler.

reverseGeocode(location:layers:completionHandler:)

Reverse geocodes a location, converting coordinates to address.
CLLocation
required
The location to reverse geocode.
Array<String>
Optional layer filters.
RadarGeocodeCompletionHandler
required
A completion handler.

ipGeocode(completionHandler:)

Geocodes the device’s current IP address, converting IP address to partial address.
RadarIPGeocodeCompletionHandler
required
A completion handler called when the request succeeds, fails, or times out.
  • status: The request status
  • address: The geocoding result (a partial address), if successful
  • proxy: A boolean indicating whether the IP address is a known proxy

validateAddress(address:completionHandler:)

Validates an address, attaching a verification status, property type, and ZIP+4.
RadarAddress
required
The address to validate.
RadarValidateAddressCompletionHandler
required
A completion handler called when the request succeeds, fails, or times out.
  • status: The request status
  • address: The validated address, if successful
  • verificationStatus: The verification status

Distance

getDistance(destination:modes:units:completionHandler:)

Gets the device’s current location, then calculates the travel distance and duration to a destination.
CLLocation
required
The destination.
RadarRouteMode
required
The travel modes.
RadarRouteUnits
required
The distance units (.imperial or .metric).
RadarRouteCompletionHandler
required
A completion handler called when the request succeeds, fails, or times out.
  • status: The request status
  • routes: The routes, if successful

getDistance(origin:destination:modes:units:completionHandler:)

Calculates the travel distance and duration from an origin to a destination.
CLLocation
required
The origin.
CLLocation
required
The destination.
RadarRouteMode
required
The travel modes.
RadarRouteUnits
required
The distance units.
RadarRouteCompletionHandler
required
A completion handler.

getMatrix(origins:destinations:mode:units:completionHandler:)

Calculates the travel distances and durations between multiple origins and destinations for up to 25 routes.
Array<CLLocation>
required
The origins.
Array<CLLocation>
required
The destinations.
RadarRouteMode
required
The travel mode.
RadarRouteUnits
required
The distance units.
RadarRouteMatrixCompletionHandler
required
A completion handler called when the request succeeds, fails, or times out.
  • status: The request status
  • matrix: The matrix, if successful

Logging

setLogLevel(_:)

Sets the preferred log level for debug logs. This can be overridden by the remote SDK configuration set in the dashboard.
RadarLogLevel
required
The log level (.none, .error, .warning, .info, or .debug).

logTermination()

Log application terminating. Include this in your application delegate’s applicationWillTerminate: method.

logBackgrounding()

Log application entering background. Include this in your application delegate’s applicationDidEnterBackground: method.

logResigningActive()

Log application resigning active. Include this in your application delegate’s applicationWillResignActive: method.

Helpers

stringForStatus(_:)

Returns a display string for a status value.
RadarStatus
required
A status value.

stringForVerificationStatus(_:)

Returns a string for address validation status value.
RadarAddressVerificationStatus
required
An address verification status value.

stringForActivityType(_:)

Returns a display string for an activity type value.
RadarActivityType
required
An activity type value.

stringForLocationSource(_:)

Returns a display string for a location source value.
RadarLocationSource
required
A location source value.

stringForMode(_:)

Returns a display string for a travel mode value.
RadarRouteMode
required
A travel mode value.

stringForTripStatus(_:)

Returns a display string for a trip status value.
RadarTripStatus
required
A trip status value.

dictionaryForLocation(_:)

Returns a dictionary for a location.
CLLocation
required
A location.

dictionaryForInAppMessage(_:)

Returns a dictionary for an in-app message.
RadarInAppMessage
required
An in-app message.