Skip to content

DriveMotionMonitorClient

TNDriveMotionMonitorClient mainly provides some monitor functions for trip upload status. developers must obtain DriveMotionMonitorClient after initializing DriveMotion.

Get TNDriveMotionMonitorClient

1
2
3
4
5
    do {
        let driveMotionMonitorClient = try TNDriveMotionService.getDriveMotionMonitorClient()
    } catch {
        // The SDK is not initialized
    }
1
2
3
4
5
    NSError *error;
    TNDriveMotionMonitorClient *driveMotionMonitorClient = [TNDriveMotionService getDriveMotionMonitorClientWithError:&error];
    if (error) {
        // The SDK is not initialized
    }

Use TNDriveMotionMonitorClient

TNDriveMotionMonitorClient provides some monitor functions for trip upload status.

Get Upload Progress Request

the TNGetUploadProgressRequest will get the trip upload progress.

Build Request

1
    let request = driveMotionMonitorClient.getUploadProgressRequest().build()
1
    TNGetUploadProgressRequest *request = [[driveMotionMonitorClient getUploadProgressRequest] build];

Create a Call and execute it

Callback is a closure accepting response and error parameters.

1
2
3
4
5
6
7
8
9
    let call = TNGetUploadProgressCall()
    call.execute(request: request) { response, error in
        if let response = response {
            // Handle response
        }
        if let error = error {
            // Handle error
        }
    }
1
2
3
4
5
6
7
8
9
     TNGetUploadProgressCall *call = [[TNGetUploadProgressCall alloc] init];
     [call executeWithRequest:request callback:^(TNGetUploadProgressResponse * _Nullable response, TNDriveMotionException * _Nullable error) {
         if (response) {
             // Handle response
         }
         if (error) {
            // Handle error
         }
     }];

Get Upload Success Timestamp

the TNGetUploadSuccessTimestampRequest will get trip upload success timestamp.

Build Request

1
    let request = driveMotionMonitorClient.getUploadSuccessTimestampRequest().build()
1
    TNGetUploadSuccessTimestampRequest *request = [[driveMotionMonitorClient getUploadSuccessTimestampRequest] build];

Create a Call and execute it

Callback is a closure accepting response and error parameters.

1
2
3
4
5
6
7
8
9
    let call = TNGetUploadSuccessTimestampCall()
    call.execute(request: request) { response, error in
        if let response = response {
            // Handle response
        }
        if let error = error {
            // Handle error
        }
    }
1
2
3
4
5
6
7
8
9
     TNGetUploadSuccessTimestampCall *call = [[TNGetUploadSuccessTimestampCall alloc] init];
     [call executeWithRequest:request callback:^(TNGetUploadSuccessTimestampResponse * _Nullable response, TNDriveMotionException * _Nullable error) {
         if (response) {
             // Handle response
         }
         if (error) {
            // Handle error
         }
     }];

Bluetooth unavailable during trip (since 3.18.0)

When edge matching is enabled, the SDK can notify your app if phone Bluetooth is off, app BT permission is not granted, or both, while a trip is already recording and no qualifying peripheral has been seen for a configurable period. The trip is not stopped; this is for in-trip diagnostics only.

Set an object that conforms to TNDriveMotionMonitorDelegate on DriveMotionSettings when you configure the DriveMotion service (see Initialize the SDK and monitor delegate wiring). An optional callback is used:

1
2
3
4
func onBluetoothUnavailableDuringTrip(_ event: TNBTUnavailableEvent) {
    // event.tripId
    // event.cause: TNBTUnavailableCauseType — .appPermissionOff, .phoneBtOff, .both, .uninitialized
}

Threshold configuration

The minimum time after trip start (and on trip interval checks) before this may fire is controlled with btUnavailableTripThresholdSec in remote dm_common_model, mapped to CommonConfig. The default in the SDK is 120 seconds if unset.