Overview
TheRadar 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
initialize(publishableKey:)
String
required
Your publishable API key.
initialize(publishableKey:options:)
String
required
Your publishable API key.
RadarInitializeOptions
Radar SDK initialization options.
Properties
sdkVersion
User Identification
setUserId(_:)
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()
userId.
setDescription(_:)
String
A description for the user. If
nil, the previous description will be cleared.getDescription()
description.
setMetadata(_:)
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()
metadata.
Tags
getTags()
tags.
setTags(_:)
Array<String>
An array of tags. If
nil, all tags will be cleared.addTags(_:)
Array<String>
required
An array of tags to add.
removeTags(_:)
Array<String>
required
An array of tags to remove.
Product
setProduct(_:)
String
A product name. If
nil, the previous product will be cleared.getProduct()
product.
Privacy
setAnonymousTrackingEnabled(_:)
trackOnce() or startTracking(). Disabled by default.
Bool
required
A boolean indicating whether anonymous tracking should be enabled.
Location
getLocation(completionHandler:)
RadarLocationCompletionHandler
An optional completion handler called when the request succeeds, fails, or times out.
status: The request statuslocation: The device’s location, if successfulstopped: Whether the device is stopped
getLocation(desiredAccuracy:completionHandler:)
RadarTrackingOptionsDesiredAccuracy
required
The desired accuracy (
.high, .medium, or .low).RadarLocationCompletionHandler
An optional completion handler.
Foreground Tracking
trackOnce(completionHandler:)
RadarTrackCompletionHandler
An optional completion handler called when the request succeeds, fails, or times out.
status: The request statuslocation: The user’s location, if successfulevents: An array of events generated, if anyuser: The user, if successful
trackOnce(desiredAccuracy:beacons:completionHandler:)
RadarTrackingOptionsDesiredAccuracy
required
The desired accuracy.
Bool
required
A boolean indicating whether to range beacons.
RadarTrackCompletionHandler
An optional completion handler.
trackOnce(location:completionHandler:)
CLLocation
required
A location for the user.
RadarTrackCompletionHandler
An optional completion handler.
Verified Tracking
trackVerified(completionHandler:)
RadarTrackVerifiedCompletionHandler
An optional completion handler called when the request succeeds, fails, or times out.
status: The request statustoken: The verified location token, if successful. Verify the token server-side using your secret key.
trackVerified(beacons:desiredAccuracy:completionHandler:)
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:)
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:)
TimeInterval
required
The default interval in seconds between each location update.
Bool
required
A boolean indicating whether to range beacons.
stopTrackingVerified()
isTrackingVerified()
getVerifiedLocationToken(completionHandler:)
RadarTrackVerifiedCompletionHandler
An optional completion handler.
getVerifiedLocationToken(beacons:desiredAccuracy:completionHandler:)
Bool
required
A boolean indicating whether to range beacons.
RadarTrackingOptionsDesiredAccuracy
required
The desired accuracy.
RadarTrackVerifiedCompletionHandler
An optional completion handler.
clearVerifiedLocationToken()
setExpectedJurisdiction(countryCode:stateCode:)
String
The user’s expected two-letter country code.
String
The user’s expected two-letter state code.
Background Tracking
startTracking(trackingOptions:)
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:)
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()
isTracking()
getTrackingOptions()
isUsingRemoteTrackingOptions()
Delegate
setDelegate(_:)
RadarDelegate
A delegate for client-side delivery of events, location updates, and debug logs. If
nil, the previous delegate will be cleared.setVerifiedDelegate(_:)
RadarVerifiedDelegate
A delegate for client-side delivery of verified location tokens. If
nil, the previous delegate will be cleared.Events
acceptEventId(_:verifiedPlaceId:)
String
required
The ID of the event to accept.
String
For place entry events, the ID of the verified place. May be
nil.rejectEventId(_:)
String
required
The ID of the event to reject.
logConversion(name:metadata:completionHandler:)
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 statusevent: The conversion event generated, if successful
logConversion(name:revenue:metadata:completionHandler:)
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:)
UNNotificationRequest
The request associated with the notification.
logConversion(response:)
UNNotificationResponse
required
The response associated with user interaction with the notification.
Trips
getTripOptions()
getTrip()
_id values when calling updateTripLeg.
startTrip(options:)
RadarTripOptions
required
Configurable trip options.
startTrip(options:completionHandler:)
RadarTripOptions
required
Configurable trip options.
RadarTripCompletionHandler
An optional completion handler called when the request succeeds, fails, or times out.
status: The request statustrip: The trip, if successfulevents: An array of events generated, if any
startTrip(options:trackingOptions:completionHandler:)
RadarTripOptions
required
Configurable trip options.
RadarTrackingOptions
Tracking options to use during the trip.
RadarTripCompletionHandler
An optional completion handler.
updateTrip(options:status:completionHandler:)
RadarTripOptions
required
Configurable trip options.
RadarTripStatus
required
The trip status. To avoid updating status, pass
RadarTripStatus.unknown.RadarTripCompletionHandler
An optional completion handler.
completeTrip()
completeTrip(completionHandler:)
RadarTripCompletionHandler
An optional completion handler.
cancelTrip()
cancelTrip(completionHandler:)
RadarTripCompletionHandler
An optional completion handler.
updateTripLeg(tripId:legId:status:completionHandler:)
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 statustrip: The trip, if successfulleg: The updated leg, if successfulevents: An array of events generated, if any
updateTripLeg(legId:status:completionHandler:)
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:)
RadarTripLegStatus
required
The new status for the current leg.
RadarTripLegCompletionHandler
An optional completion handler.
reorderTripLegs(tripId:legIds:completionHandler:)
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:)
Array<String>
required
An array of leg IDs in the desired new order.
RadarTripCompletionHandler
An optional completion handler.
Context
getContext(completionHandler:)
RadarContextCompletionHandler
required
A completion handler called when the request succeeds, fails, or times out.
status: The request statuslocation: The location, if successfulcontext: The context, if successful
getContext(location:completionHandler:)
CLLocation
required
The location.
RadarContextCompletionHandler
required
A completion handler.
Search
searchPlaces(radius:chains:categories:groups:countryCodes:limit:completionHandler:)
Int
required
The radius to search, in meters. A number between 100 and 10000.
Array<String>
An array of categories to filter. See Categories.
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 statuslocation: The location, if successfulplaces: An array of places sorted by distance, if successful
searchPlaces(radius:chains:chainMetadata:categories:groups:countryCodes:limit:completionHandler:)
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:)
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:)
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:)
RadarSearchGeofencesCompletionHandler
required
A completion handler called when the request succeeds, fails, or times out.
status: The request statuslocation: The location, if successfulgeofences: An array of geofences sorted by distance, if successful
searchGeofences(near:radius:tags:metadata:limit:includeGeometry:completionHandler:)
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:)
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 statusaddresses: The geocoding results (an array of addresses), if successful
autocomplete(query:near:layers:limit:country:completionHandler:)
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:)
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:)
String
required
The address to geocode.
RadarGeocodeCompletionHandler
required
A completion handler.
geocode(address:layers:countries:completionHandler:)
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:)
RadarGeocodeCompletionHandler
required
A completion handler.
reverseGeocode(layers:completionHandler:)
Array<String>
Optional layer filters.
RadarGeocodeCompletionHandler
required
A completion handler.
reverseGeocode(location:completionHandler:)
CLLocation
required
The location to reverse geocode.
RadarGeocodeCompletionHandler
required
A completion handler.
reverseGeocode(location:layers:completionHandler:)
CLLocation
required
The location to reverse geocode.
Array<String>
Optional layer filters.
RadarGeocodeCompletionHandler
required
A completion handler.
ipGeocode(completionHandler:)
RadarIPGeocodeCompletionHandler
required
A completion handler called when the request succeeds, fails, or times out.
status: The request statusaddress: The geocoding result (a partial address), if successfulproxy: A boolean indicating whether the IP address is a known proxy
validateAddress(address:completionHandler:)
RadarAddress
required
The address to validate.
RadarValidateAddressCompletionHandler
required
A completion handler called when the request succeeds, fails, or times out.
status: The request statusaddress: The validated address, if successfulverificationStatus: The verification status
Distance
getDistance(destination:modes:units:completionHandler:)
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 statusroutes: The routes, if successful
getDistance(origin:destination:modes:units:completionHandler:)
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:)
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 statusmatrix: The matrix, if successful
Logging
setLogLevel(_:)
RadarLogLevel
required
The log level (
.none, .error, .warning, .info, or .debug).logTermination()
applicationWillTerminate: method.
logBackgrounding()
applicationDidEnterBackground: method.
logResigningActive()
applicationWillResignActive: method.
Helpers
stringForStatus(_:)
RadarStatus
required
A status value.
stringForVerificationStatus(_:)
RadarAddressVerificationStatus
required
An address verification status value.
stringForActivityType(_:)
RadarActivityType
required
An activity type value.
stringForLocationSource(_:)
RadarLocationSource
required
A location source value.
stringForMode(_:)
RadarRouteMode
required
A travel mode value.
stringForTripStatus(_:)
RadarTripStatus
required
A trip status value.
dictionaryForLocation(_:)
CLLocation
required
A location.
dictionaryForInAppMessage(_:)
RadarInAppMessage
required
An in-app message.