Skip to main content
RadarGeofence represents a geofence. Learn more about Geofences.

Properties

_id
String
required
The Radar ID of the geofence.
__description
String
required
The description of the geofence. Not to be confused with the NSObject description property.
tag
String
The tag of the geofence.
externalId
String
The external ID of the geofence.
metadata
NSDictionary
The optional set of custom key-value pairs for the geofence.
geometry
RadarGeofenceGeometry
required
The geometry of the geofence, which can be cast to either RadarCircleGeometry or RadarPolygonGeometry.
operatingHours
RadarOperatingHours
The optional operating hours for the geofence.

Methods

arrayForGeofences

+ (NSArray<NSDictionary *> *_Nullable)arrayForGeofences:(NSArray<RadarGeofence *> *_Nullable)geofences;
Converts an array of RadarGeofence objects to an array of dictionaries.

dictionaryValue

- (NSDictionary *_Nonnull)dictionaryValue;
Returns the dictionary representation of the geofence.

Example

let geofence: RadarGeofence = event.geofence
let geofenceId = geofence._id
let geofenceDescription = geofence.__description
let geofenceTag = geofence.tag
let geofenceExternalId = geofence.externalId
let geofenceMetadata = geofence.metadata

if let circleGeometry = geofence.geometry as? RadarCircleGeometry {
    let center = circleGeometry.center
    let radius = circleGeometry.radius
} else if let polygonGeometry = geofence.geometry as? RadarPolygonGeometry {
    let center = polygonGeometry.center
    let radius = polygonGeometry.radius
    let coordinates = polygonGeometry._coordinates
}
RadarGeofence *geofence = event.geofence;
NSString *geofenceId = geofence._id;
NSString *geofenceDescription = geofence.__description;
NSString *geofenceTag = geofence.tag;
NSString *geofenceExternalId = geofence.externalId;
NSDictionary *geofenceMetadata = geofence.metadata;

if ([geofence.geometry isKindOfClass:[RadarCircleGeometry class]]) {
    RadarCircleGeometry *circleGeometry = (RadarCircleGeometry *)geofence.geometry;
    RadarCoordinate *center = circleGeometry.center;
    double radius = circleGeometry.radius;
} else if ([geofence.geometry isKindOfClass:[RadarPolygonGeometry class]]) {
    RadarPolygonGeometry *polygonGeometry = (RadarPolygonGeometry *)geofence.geometry;
    RadarCoordinate *center = polygonGeometry.center;
    double radius = polygonGeometry.radius;
    NSArray<RadarCoordinate *> *coordinates = polygonGeometry._coordinates;
}