Geofencing

Last Updated on : 2024-07-10 09:00:41download

This topic describes the geofencing features.

Concepts

LBS

Location-based services (LBS) are software services that use geographic data and information to provide services to users. With the control database, the mobile client can access users’ geographic coordinates through the wireless communication network or satellite navigation system. This information is then integrated with other data to offer location-based services.

Geofencing

Geofencing is a new LBS application that creates a virtual perimeter around a physical location. Like a real fence, a geofence creates a separation between that location and the area around it. Unlike a real fence, it can detect movement inside the virtual boundary. When a device enters or leaves a specific area, users will receive notifications.

Geofencing applications

To create a geofence for travel devices, specify the radius with the device’s current location as the central point. The following describes how to use the standard geofencing features.

UserMobile AppCloudVehicleGeofencing enabledEnable geofencingEnabled successfullyGeofencing activatedReport GPS when lockingReport GPS after lockingQuery vehicle locking status and location informationThe locked vehicle leaves thegeofenceTrigger an alertUserMobile AppCloudVehicle
  • Enable geofencing and set alerts: Use the geofencing setup method to enable this feature and set alert preferences, such as app notifications, SMS messages, and phone calls.

  • Location of the geofence center: Usually the location where the vehicle was last locked, changing as the vehicle moves. When the vehicle is locked, it reports its current location. An alert will be triggered if the reported location deviates beyond the specified radius. Set the respective DP to receive an alert when the status of other features changes.

    These features allow users to monitor vehicle location and receive live alerts when unusual activities occur.

Geofencing services

Class (protocol) Description
TSODGeofenceService Geofencing services
TSODGeofenceModel Geofence information model

Set a geofence

- (void)setGeofenceWithRequestModel:(TSODGeofenceModel *)requestModel
                            success:(nullable ThingSuccessBOOL)success
                            failure:(nullable ThingFailureError)failure NS_SWIFT_NAME(setGeofence(requestModel:success:failure:));

Example

    TSODGeofenceModel *requestModel = [[TSODGeofenceModel alloc] init];
    requestModel.devID = self.device.deviceModel.devId;
    requestModel.geofenceInfo.open = YES;
    requestModel.geofenceInfo.radius = 50;
    requestModel.geofenceInfo.noticeType = noticeType;
    requestModel.geofenceInfo.dpCode = @"blelock_switch";
    requestModel.geofenceInfo.dpValue = @NO;

    self.service = [[TSODGeofenceService alloc] init]
    [self.service setGeofenceWithRequestModel:requestModel success:^(**BOOL** result) {
		//...
    } failure:^(NSError *error) {

    }];

Get geofence information

- (void)getGeofenceInfoWithDevID:(NSString *)devID
                         success:(nullable void(^)(TSODGeofenceModel *geofenceModel))success
                         failure:(nullable ThingFailureError)failure NS_SWIFT_NAME(getGeofenceInfo(devID:success:failure:));

Example

self.service = [[TSODGeofenceService alloc] init]
[self.service getGeofenceInfoWithDevID:self.deviceModel.devId success:^(TSODGeofenceModel * _Nonnull geofenceModel) {
        BOOL isOpen = geofenceModel.geofenceInfo.isOpen;
        //...
    } failure:^(NSError *error) {

    }];

Data model of TSODGeofenceModel

Field Type Description
devID NSString The device ID.
geofenceInfo TSODGeofenceInfoModel The geofence information.

Data model of TSODGeofenceInfoModel

Field Type Description
radius NSInteger The radius of the geofence, in meters. With geofencing enabled, the radius must be greater than 0.
noticeType TSODGeofenceNoticeType The alert type, including app notifications, SMS messages, and phone calls. The SMS and phone call services require a separate purchase.
open BOOL Specifies whether to enable geofencing.
dpCode NSString The associated DP. Typically, the code of this DP determines whether to trigger the geofence. If you use the standard solution, associate the locking DP.
dpValue id The value of the desired DP activated by geofencing. To activate geofencing when the vehicle is locked, set the value to @NO.