Features and Modifications
Zendrive SDK provides a number of features that you can use to control how and when trips are detected and where you can implement your business logic.
Collision Detection
By default, collision detection is enabled in Zendrive SDK and is active when a drive is in progress. Register your event listener using the Zendrive.registerZendriveCallbackEventListener
method. When your listener is notified with event of kind on-accident
, you can process collision data.
Testing Collision Detection
After setting up Zendrive SDK in collision-detection mode, you can test your integration using the Zendrive.triggerMockAccident
method. This emulates a fake collision and notifies event of kind on-accident
on your registered listener.
import Zendrive from 'react-native-zendrive';
// .....
Zendrive.triggerMockAccident('high').then(response => {
if (response.isSuccess) {
console.log('fake accident triggered');
} else {
console.log(response.errorCode);
console.log(response.errorMessage);
}
});
To emulate multiple on-potential-accident
event, you can use the following snippet:
import Zendrive from 'react-native-zendrive';
// .....
Zendrive.triggerMockAccident({
delayBetweenCallbacksSeconds: 15,
finalCallbackConfidence: 'high',
finalCallbackConfidenceNumber: 75,
potentialCallbackConfidence: 'high',
potentialCallbackConfidenceNumber: 85,
}).then(response => {
if (response.isSuccess) {
console.log('fake accident triggered');
} else {
console.log(response.errorCode);
console.log(response.errorMessage);
}
});
Both of the trigger accident callbacks requires the SDK to be set up and a trip to be in progress.
Manual Trip Tagging
Zendrive SDK works in the background and automatically detects trips and tracks driving behaviour. However, some applications, such as taxi-metering applications, already have knowledge of point-to-point trips made by the driver using the application.
If your application has this knowledge, you can import it to Zendrive SDK by using the following code:
import Zendrive from 'react-native-zendrive';
// ....
// provide a valid tracking id, use Zendrive.isValidInputParameter if needed.
const trackingId = '<tracking-id>';
Zendrive.startDrive(trackingId).then(response => {
if (response.isSuccess) {
console.log('Drive start operation succeeded');
} else {
console.log(response.errorCode);
console.log(response.errorMessage);
}
});
Your application can then use the <tracking-id>
argument to find Zendrive trips with this ID in the Zendrive Analytics API. See the SDK Reference for more information.
Driving Sessions
Some applications want to track multiple point-to-point trips together as a single entity. For example, a car rental application may want to track all trips made by a user between a rental car pick-up and drop-off as a single entity. You can do this using the sessions
method in Zendrive SDK, via the following calls:
import Zendrive from 'react-native-zendrive';
// ...
// provide a valid session id, use Zendrive.isValidInputParameter if needed.
const sessionId = '<session-id>';
Zendrive.startSession(sessionId).then(response => {
if (response.isSuccess) {
console.log('Start session operation succeeded');
} else {
console.log(response.errorCode);
console.log(response.errorMessage);
}
});
// ...
// sometime later as per your business logic you can stop the session
Zendrive.stopSession();
Zendrive SDK tags all trips within a session with a single session ID. You can use the session ID to lookup Zendrive trips belonging to a given session using the Zendrive Analytics API. See the SDK Reference for more information.
Controlling Automatic Drive Detection
The Zendrive SDK works in the background and automatically detects trips and tracks driving behaviour. If needed, an application can change this behaviour. For example, a ride-sharing application may want to automatically track all trips only when the drive is on duty.
The application can specify the required behaviour during Zendrive SDK set up, as shown below:
Zendrive.setup({
driverId: '<driver_id>',
sdkKey: '<sdk_key>',
driveDetectionMode: 'auto-off',
}).then(response => {
if (response.isSuccess) {
console.log('sdk setup succeeded');
} else {
console.log('sdk setup failed');
console.log(response.errorCode);
console.log(response.errorMessage);
}
});
The application can also temporarily enable Zendrive's automatic trip detection. This can be done by setting the Zendrive.setZendriveDriveDetectionMode,
as follows:
// Turn on automatic drive detection in the SDK.
Zendrive.setZendriveDriveDetectionMode('auto-on').then(response => {
if (response.isSuccess) {
console.log('temporarily enabled auto-on drive detection mode');
} else {
console.log('sdk setup failed');
console.log(response.errorCode);
console.log(response.errorMessage);
}
});
// Turn off automatic drive detection in the SDK.
Zendrive.setZendriveDriveDetectionMode('auto-off').then(response => {
if (response.isSuccess) {
console.log('temporarily enabled auto-off drive detection mode');
} else {
console.log('sdk setup failed');
console.log(response.errorCode);
console.log(response.errorMessage);
}
});
Vehicle Tagging
Vehicle Tagging involves methods to associate and disassociate a vehicle for tagging, and much more. Click here for more information on Vehicle Tagging.
Pause Auto Trip Tracking
Refer Pause Auto Tracking to understand complete details of the feature.
Business Hours
Refer Business Hours APIs to understand complete details about the feature.
Last updated
Was this helpful?