Radar

@interface Radar : NSObject

The main class used to interact with the Radar SDK.

  • Initializes the Radar SDK.

    Warning

    Call this method from the main thread in your AppDelegate class before calling any other Radar methods.

    Declaration

    Objective-C

    + (void)initializeWithPublishableKey:(NSString *_Nonnull)publishableKey;

    Swift

    class func initialize(publishableKey: String)

    Parameters

    publishableKey

    Your publishable API key.

  • Identifies the user.

    Note

    Until you identify the user, Radar will automatically identify the user by deviceId (IDFV).

    Declaration

    Objective-C

    + (void)setUserId:(NSString *_Nullable)userId;

    Swift

    class func setUserId(_ userId: String?)

    Parameters

    userId

    A stable unique ID for the user. If nil, the previous userId will be cleared.

  • Returns the current userId.

    Declaration

    Objective-C

    + (NSString *_Nullable)getUserId;

    Swift

    class func getUserId() -> String?

    Return Value

    The current userId.

  • Sets an optional description for the user, displayed in the dashboard.

    Declaration

    Objective-C

    + (void)setDescription:(NSString *_Nullable)description;

    Swift

    class func setDescription(_ description: String?)

    Parameters

    description

    A description for the user. If nil, the previous description will be cleared.

  • Returns the current description.

    Declaration

    Objective-C

    + (NSString *_Nullable)getDescription;

    Swift

    class func getDescription() -> String?

    Return Value

    The current description.

  • Sets an optional set of custom key-value pairs for the user.

    Declaration

    Objective-C

    + (void)setMetadata:(NSDictionary *_Nullable)metadata;

    Swift

    class func setMetadata(_ metadata: [AnyHashable : Any]?)

    Parameters

    metadata

    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.

  • Returns the current metadata.

    Declaration

    Objective-C

    + (NSDictionary *_Nullable)getMetadata;

    Swift

    class func getMetadata() -> [AnyHashable : Any]?

    Return Value

    The current metadata.

  • Enables adId (IDFA) collection.

    Declaration

    Objective-C

    + (void)setAdIdEnabled:(BOOL)enabled;

    Swift

    class func setAdIdEnabled(_ enabled: Bool)

    Parameters

    enabled

    A boolean indicating whether adId should be collected.

  • Gets the device’s current location.

    Declaration

    Objective-C

    + (void)getLocationWithCompletionHandler:
        (RadarLocationCompletionHandler _Nullable)completionHandler;

    Swift

    class func getLocation(completionHandler: RadarLocationCompletionHandler? = nil)

    Parameters

    completionHandler

    An optional completion handler.

  • Gets the device’s current location with the desired accuracy.

    Declaration

    Objective-C

    + (void)getLocationWithDesiredAccuracy:
                (RadarTrackingOptionsDesiredAccuracy)desiredAccuracy
                         completionHandler:
                             (RadarLocationCompletionHandler _Nullable)
                                 completionHandler;

    Swift

    class func getLocation(desiredAccuracy: RadarTrackingOptionsDesiredAccuracy, completionHandler: RadarLocationCompletionHandler? = nil)

    Parameters

    desiredAccuracy

    The desired accuracy.

    completionHandler

    An optional completion handler.

  • Tracks the user’s location once in the foreground.

    Warning

    Note that these calls are subject to rate limits.

    Declaration

    Objective-C

    + (void)trackOnceWithCompletionHandler:
        (RadarTrackCompletionHandler _Nullable)completionHandler;

    Swift

    class func trackOnce(completionHandler: RadarTrackCompletionHandler? = nil)

    Parameters

    completionHandler

    An optional completion handler.

  • Manually updates the user’s location.

    Warning

    Note that these calls are subject to rate limits.

    Declaration

    Objective-C

    + (void)trackOnceWithLocation:(CLLocation *_Nonnull)location
                completionHandler:
                    (RadarTrackCompletionHandler _Nullable)completionHandler;

    Swift

    class func trackOnce(location: CLLocation, completionHandler: RadarTrackCompletionHandler? = nil)

    Parameters

    location

    A location for the user.

    completionHandler

    An optional completion handler.

  • Starts tracking the user’s location in the background with configurable tracking options.

    Declaration

    Objective-C

    + (void)startTrackingWithOptions:(nonnull RadarTrackingOptions *)options;

    Swift

    class func startTracking(trackingOptions options: RadarTrackingOptions)

    Parameters

    options

    Configurable tracking options.

  • Mocks tracking the user’s location from an origin to a destination.

    Declaration

    Objective-C

    + (void)mockTrackingWithOrigin:(CLLocation *_Nonnull)origin
                       destination:(CLLocation *_Nonnull)destination
                              mode:(RadarRouteMode)mode
                             steps:(int)steps
                          interval:(NSTimeInterval)interval
                 completionHandler:
                     (RadarTrackCompletionHandler _Nullable)completionHandler;

    Swift

    class func mockTracking(origin: CLLocation, destination: CLLocation, mode: RadarRouteMode, steps: Int32, interval: TimeInterval, completionHandler: RadarTrackCompletionHandler? = nil)

    Parameters

    origin

    The origin.

    destination

    The destination.

    mode

    The travel mode.

    steps

    The number of mock location updates.

    interval

    The interval in seconds between each mock location update. A number between 1 and 60.

  • Stops tracking the user’s location in the background.

    Declaration

    Objective-C

    + (void)stopTracking;

    Swift

    class func stopTracking()
  • Returns a boolean indicating whether tracking has been started.

    Declaration

    Objective-C

    + (BOOL)isTracking;

    Swift

    class func isTracking() -> Bool

    Return Value

    A boolean indicating whether tracking has been started.

  • Returns the current tracking options.

    Declaration

    Objective-C

    + (nonnull RadarTrackingOptions *)getTrackingOptions;

    Swift

    class func getTrackingOptions() -> RadarTrackingOptions

    Return Value

    The current tracking options.

  • Sets a delegate for client-side delivery of events, location updates, and debug logs.

    Declaration

    Objective-C

    + (void)setDelegate:(nullable id<RadarDelegate>)delegate;

    Parameters

    delegate

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

  • 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.

    Declaration

    Objective-C

    + (void)acceptEventId:(NSString *_Nonnull)eventId
          verifiedPlaceId:(NSString *_Nullable)verifiedPlaceId;

    Swift

    class func acceptEventId(_ eventId: String, verifiedPlaceId: String?)

    Parameters

    eventId

    The ID of the event to accept.

    verifiedPlaceId

    For place entry events, the ID of the verified place. May be nil.

  • Rejects 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.

    Declaration

    Objective-C

    + (void)rejectEventId:(NSString *_Nonnull)eventId;

    Swift

    class func rejectEventId(_ eventId: String)

    Parameters

    eventId

    The ID of the event to reject.

  • Returns the current trip options.

    Declaration

    Objective-C

    + (RadarTripOptions *_Nullable)getTripOptions;

    Swift

    class func getTripOptions() -> RadarTripOptions?

    Return Value

    The current trip options.

  • Starts a trip.

    Declaration

    Objective-C

    + (void)startTripWithOptions:(RadarTripOptions *_Nonnull)options;

    Swift

    class func startTrip(options: RadarTripOptions)

    Parameters

    options

    Configurable trip options.

  • Stops a trip.

    Declaration

    Objective-C

    + (void)stopTrip;

    Swift

    class func stopTrip()
  • Gets the device’s current location, then gets context for that location without sending device or user identifiers to the server.

    Declaration

    Objective-C

    + (void)getContextWithCompletionHandler:
        (RadarContextCompletionHandler _Nonnull)completionHandler;

    Swift

    class func getContext(completionHandler: @escaping RadarContextCompletionHandler)

    Parameters

    completionHandler

    An optional completion handler.

  • Gets context for a location without sending device or user identifiers to the server.

    Declaration

    Objective-C

    + (void)getContextForLocation:(CLLocation *_Nonnull)location
                completionHandler:
                    (RadarContextCompletionHandler _Nonnull)completionHandler;

    Swift

    class func getContext(location: CLLocation, completionHandler: @escaping RadarContextCompletionHandler)

    Parameters

    location

    The location.

    completionHandler

    An optional completion handler.

  • Gets the device’s current location, then searches for places near that location, sorted by distance.

    Warning

    You may specify only one of chains, categories, or groups.

    Declaration

    Objective-C

    + (void)searchPlacesWithRadius:(int)radius
                            chains:(NSArray *_Nullable)chains
                        categories:(NSArray *_Nullable)categories
                            groups:(NSArray *_Nullable)groups
                             limit:(int)limit
                 completionHandler:
                     (RadarSearchPlacesCompletionHandler)completionHandler;

    Swift

    class func searchPlaces(radius: Int32, chains: [Any]?, categories: [Any]?, groups: [Any]?, limit: Int32, completionHandler: @escaping RadarSearchPlacesCompletionHandler)

    Parameters

    radius

    The radius to search, in meters. A number between 100 and 10000.

    chains

    An array of chain slugs to filter. See https://radar.io/documentation/places/chains

    categories

    An array of categories to filter. See: https://radar.io/documentation/places/categories

    groups

    An array of groups to filter. See https://radar.io/documentation/places/groups

    limit

    The max number of places to return. A number between 1 and 100.

    completionHandler

    A completion handler.

  • Searches for places near a location, sorted by distance.

    Warning

    You may specify only one of chains, categories, or groups.

    Declaration

    Objective-C

    + (void)searchPlacesNear:(nonnull CLLocation *)near
                      radius:(int)radius
                      chains:(NSArray *_Nullable)chains
                  categories:(NSArray *_Nullable)categories
                      groups:(NSArray *_Nullable)groups
                       limit:(int)limit
           completionHandler:(RadarSearchPlacesCompletionHandler)completionHandler;

    Swift

    class func searchPlaces(near: CLLocation, radius: Int32, chains: [Any]?, categories: [Any]?, groups: [Any]?, limit: Int32, completionHandler: @escaping RadarSearchPlacesCompletionHandler)

    Parameters

    near

    The location to search.

    radius

    The radius to search, in meters. A number between 100 and 10000.

    chains

    An array of chain slugs to filter. See https://radar.io/documentation/places/chains

    categories

    An array of categories to filter. See: https://radar.io/documentation/places/categories

    groups

    An array of groups to filter. See https://radar.io/documentation/places/groups

    limit

    The max number of places to return. A number between 1 and 100.

    completionHandler

    A completion handler.

  • Gets the device’s current location, then searches for geofences near that location, sorted by distance.

    Declaration

    Objective-C

    + (void)searchGeofencesWithRadius:(int)radius
                                 tags:(NSArray *_Nullable)tags
                             metadata:(NSDictionary *_Nullable)metadata
                                limit:(int)limit
                    completionHandler:
                        (RadarSearchGeofencesCompletionHandler)completionHandler;

    Swift

    class func searchGeofences(radius: Int32, tags: [Any]?, metadata: [AnyHashable : Any]?, limit: Int32, completionHandler: @escaping RadarSearchGeofencesCompletionHandler)

    Parameters

    radius

    The radius to search, in meters. A number between 100 and 10000.

    tags

    An array of tags to filter. See https://radar.io/documentation/geofences

    metadata

    A dictionary of metadata to filter. See https://radar.io/documentation/geofences

    limit

    The max number of geofences to return. A number between 1 and 100.

    completionHandler

    A completion handler.

  • Searches for geofences near a location, sorted by distance.

    Declaration

    Objective-C

    + (void)searchGeofencesNear:(nonnull CLLocation *)near
                         radius:(int)radius
                           tags:(NSArray *_Nullable)tags
                       metadata:(NSDictionary *_Nullable)metadata
                          limit:(int)limit
              completionHandler:
                  (RadarSearchGeofencesCompletionHandler)completionHandler;

    Swift

    class func searchGeofences(near: CLLocation, radius: Int32, tags: [Any]?, metadata: [AnyHashable : Any]?, limit: Int32, completionHandler: @escaping RadarSearchGeofencesCompletionHandler)

    Parameters

    near

    The location to search.

    radius

    The radius to search, in meters. A number between 100 and 10000.

    tags

    An array of tags to filter. See https://radar.io/documentation/geofences

    metadata

    A dictionary of metadata to filter. See https://radar.io/documentation/geofences

    limit

    The max number of geofences to return. A number between 1 and 100.

    completionHandler

    A completion handler.

  • Gets the device’s current location, then searches for points near that location, sorted by distance.

    Declaration

    Objective-C

    + (void)searchPointsWithRadius:(int)radius
                              tags:(NSArray<NSString *> *_Nullable)tags
                             limit:(int)limit
                 completionHandler:
                     (RadarSearchPointsCompletionHandler)completionHandler;

    Swift

    class func searchPoints(radius: Int32, tags: [String]?, limit: Int32, completionHandler: @escaping RadarSearchPointsCompletionHandler)

    Parameters

    radius

    The radius to search, in meters. A number between 100 and 10000.

    tags

    An array of tags to filter. See https://radar.io/documentation/points

    limit

    The max number of points to return. A number between 1 and 100.

    completionHandler

    A completion handler.

  • Searches for points near a location, sorted by distance.

    Declaration

    Objective-C

    + (void)searchPointsNear:(nonnull CLLocation *)near
                      radius:(int)radius
                        tags:(NSArray<NSString *> *_Nullable)tags
                       limit:(int)limit
           completionHandler:(RadarSearchPointsCompletionHandler)completionHandler;

    Swift

    class func searchPoints(near: CLLocation, radius: Int32, tags: [String]?, limit: Int32, completionHandler: @escaping RadarSearchPointsCompletionHandler)

    Parameters

    near

    The location to search.

    radius

    The radius to search, in meters. A number between 100 and 10000.

    tags

    An array of tags to filter. See https://radar.io/documentation/points

    limit

    The max number of points to return. A number between 1 and 100.

    completionHandler

    A completion handler.

  • Autocompletes partial addresses and place names, sorted by relevance.

    Declaration

    Objective-C

    + (void)autocompleteQuery:(NSString *_Nonnull)query
                         near:(CLLocation *_Nonnull)near
                        limit:(int)limit
            completionHandler:(RadarGeocodeCompletionHandler)completionHandler;

    Swift

    class func autocomplete(query: String, near: CLLocation, limit: Int32, completionHandler: @escaping RadarGeocodeCompletionHandler)

    Parameters

    query

    The partial address or place name to autocomplete.

    near

    A location for the search.

    limit

    The max number of addresses to return. A number between 1 and 100.

    completionHandler

    A completion handler.

  • Geocodes an address, converting address to coordinates.

    Declaration

    Objective-C

    + (void)geocodeAddress:(NSString *_Nonnull)query
         completionHandler:(RadarGeocodeCompletionHandler)completionHandler;

    Swift

    class func geocode(address query: String, completionHandler: @escaping RadarGeocodeCompletionHandler)

    Parameters

    query

    The address to geocode.

    completionHandler

    A completion handler.

  • Gets the device’s current location, then reverse geocodes that location, converting coordinates to address.

    Declaration

    Objective-C

    + (void)reverseGeocodeWithCompletionHandler:
        (RadarGeocodeCompletionHandler)completionHandler;

    Swift

    class func reverseGeocode(completionHandler: @escaping RadarGeocodeCompletionHandler)

    Parameters

    completionHandler

    A completion handler.

  • Reverse geocodes a location, converting coordinates to address.

    Declaration

    Objective-C

    + (void)reverseGeocodeLocation:(CLLocation *_Nonnull)location
                 completionHandler:(RadarGeocodeCompletionHandler)completionHandler;

    Swift

    class func reverseGeocode(location: CLLocation, completionHandler: @escaping RadarGeocodeCompletionHandler)

    Parameters

    location

    The location to reverse geocode.

    completionHandler

    A completion handler.

  • Geocodes the device’s current IP address, converting IP address to partial address.

    Declaration

    Objective-C

    + (void)ipGeocodeWithCompletionHandler:
        (RadarIPGeocodeCompletionHandler)completionHandler;

    Swift

    class func ipGeocode(completionHandler: @escaping RadarIPGeocodeCompletionHandler)

    Parameters

    completionHandler

    A completion handler.

  • Gets the device’s current location, then calculates the travel distance and duration to a destination.

    Declaration

    Objective-C

    + (void)getDistanceToDestination:(CLLocation *_Nonnull)destination
                               modes:(RadarRouteMode)modes
                               units:(RadarRouteUnits)units
                   completionHandler:(RadarRouteCompletionHandler)completionHandler;

    Swift

    class func getDistance(destination: CLLocation, modes: RadarRouteMode, units: RadarRouteUnits, completionHandler: @escaping RadarRouteCompletionHandler)

    Parameters

    destination

    The destination.

    modes

    The travel modes.

    units

    The distance units.

    completionHandler

    A completion handler.

  • Calculates the travel distance and duration from an origin to a destination.

    Declaration

    Objective-C

    + (void)getDistanceFromOrigin:(CLLocation *_Nonnull)origin
                      destination:(CLLocation *_Nonnull)destination
                            modes:(RadarRouteMode)modes
                            units:(RadarRouteUnits)units
                completionHandler:(RadarRouteCompletionHandler)completionHandler;

    Swift

    class func getDistance(origin: CLLocation, destination: CLLocation, modes: RadarRouteMode, units: RadarRouteUnits, completionHandler: @escaping RadarRouteCompletionHandler)

    Parameters

    origin

    The origin.

    destination

    The destination.

    modes

    The travel modes.

    units

    The distance units.

    completionHandler

    A completion handler.

  • Sets the log level for debug logs.

    Declaration

    Objective-C

    + (void)setLogLevel:(RadarLogLevel)level;

    Swift

    class func setLogLevel(_ level: RadarLogLevel)

    Parameters

    level

    The log level.

  • Returns a display string for a status value.

    Declaration

    Objective-C

    + (nonnull NSString *)stringForStatus:(RadarStatus)status;

    Swift

    class func stringForStatus(_ status: RadarStatus) -> String

    Parameters

    status

    A status value.

    Return Value

    A display string for the status value.

  • Returns a display string for a location source value.

    Declaration

    Objective-C

    + (nonnull NSString *)stringForSource:(RadarLocationSource)source;

    Swift

    class func stringForSource(_ source: RadarLocationSource) -> String

    Parameters

    source

    A location source value.

    Return Value

    A display string for the location source value.

  • Returns a display string for a travel mode value.

    Declaration

    Objective-C

    + (nonnull NSString *)stringForMode:(RadarRouteMode)mode;

    Swift

    class func stringForMode(_ mode: RadarRouteMode) -> String

    Parameters

    mode

    A travel mode value.

    Return Value

    A display string for the travel mode value.

  • Returns a dictionary for a location.

    Declaration

    Objective-C

    + (nonnull NSDictionary *)dictionaryForLocation:(nonnull CLLocation *)location;

    Swift

    class func dictionaryForLocation(_ location: CLLocation) -> [AnyHashable : Any]

    Parameters

    location

    A location.

    Return Value

    A dictionary for the location.