LogoLogo
ProductsUse casesDocsSupport
  • Introducing DriveKit
  • DriveKit Guides
  • Get started with drivekit
    • Trip recording lifecycle
    • iOS
      • 🚀Quick start
      • Advanced configurations
      • References
      • iOS DriveKit Demo App
    • Android
      • 🚀Quick start
      • Advanced configurations
      • References
      • Android DriveKit Demo App
      • Android 15 Migration guide
      • Android 14 Migration guide
      • Troubleshooting
  • Trip analysis
    • Introduction
    • iOS
      • Permissions
      • Trip management
      • TripListener
      • Crash Detection
      • Beacon usage
      • Bluetooth usage
      • Custom metadata
      • References (iOS)
    • Android
      • Runtime permissions
      • Trip management
      • TripListener
      • Crash Detection
      • Beacon usage
      • Bluetooth usage
      • Custom metadata
      • References (Android)
    • User interface
      • iOS
        • Get started
        • Working hours
        • Driver alert in case of crash
        • Trip recording widget
        • Location sharing
      • Android
        • Get started
        • Working hours
        • Driver alert in case of crash
        • Trip recording widget
        • Location sharing
    • REST services
      • Trip
      • References
    • Trip Simulator
      • iOS
      • Android
  • PERMISSIONS UTILS
    • Introduction
    • User interface
      • iOS
        • Get started
        • Main configurations
      • Android
        • Get started
        • Main configurations
  • COMMON UI
    • Introduction
    • iOS
      • Get started
    • Android
      • Get started
    • References
  • DRIVER DATA
    • Introduction
    • iOS
      • Get started
      • References (iOS)
    • Android
      • Get started
      • References (Android)
    • User interface
      • iOS
        • Get started
        • Advanced configurations
        • Trips widgets
        • My Synthesis
        • My Driver Profile
      • Android
        • Get Started
        • Advanced configurations
        • Trips widgets
        • My Synthesis
        • My Driver Profile
  • Driver Data Timeline UI
    • Introduction
    • iOS
      • Get started
    • Android
      • Get started
  • Vehicle
    • Introduction
    • iOS
      • Get started
      • Vehicle management
      • Beacon management
      • Bluetooth device management
      • Odometer
      • References (iOS)
    • Android
      • Get started
      • Vehicle management
      • Beacon management
      • Bluetooth device management
      • Odometer
      • References (Android)
    • User interface
      • iOS
        • Get started
        • Main configurations
        • Advanced configurations
      • Android
        • Get started
        • Main configurations
        • Advanced configurations
  • DRIVER ACHIEVEMENT
    • Introduction
    • iOS
      • Get started
    • Android
      • Get Started
    • User interface
      • iOS
      • Android
  • CHALLENGE
    • Introduction
    • Important challenge rules
    • iOS
      • Get started
      • References (iOS)
    • Android
      • Get started
      • References (Android)
    • User interface
      • iOS
        • Get started
      • Android
        • Get started
  • GROUP
    • Introduction
    • iOS
      • Get started
    • Android
      • Get started
  • React Native
    • Get started
    • Integration
  • Flutter
    • Get started
    • Integration
  • Push services
    • Introduction
    • Push Trip Data
    • Push Deleted trip
    • Push Crash Data
    • Push Diagnosis Data
  • ADMIN SERVICES
    • Beacon
      • Add
      • Replace
      • Delete
      • Configuration
    • Challenges
      • List of challenges
      • Challenge details
      • Registered users
      • Challenge ranking
      • Users' progress
      • Definitions
    • Customer
      • Activity timeline
    • Driver
      • Timeline
      • Synthesis
      • Identity
      • Status
      • Add or update a metadata
      • Vehicles
      • Profile
      • Application diagnoses
    • Drivers
      • Account
      • Statistics
      • Ranking
      • Expired accounts
    • Group
      • Timeline
      • Synthesis
    • Trips
      • Add or update a metadata
      • Delete a metadata
    • Vehicle
      • Create
      • Characteristics
      • Configuration
      • Statistics
      • Update mileage
      • Tire and brake wear update
      • References
  • Crashes
    • Annotate a crash
    • Revoke crash location URL
  • ENTERPRISE SERVICES
    • Introduction
    • Teams
      • Create a team
      • List of teams
      • Enable or disable a team
    • Hyper-admins
      • Create a hyper-admin
      • List of hyper-admins
      • Delete a hyper-admin
    • Monitoring
      • Get a push trip data report
      • Get a push crash data report
      • Request to retry failed trips
      • Request to retry failed crashes
      • Get the status of a task
  • Release notes
    • Changelog
      • iOS
      • Android
      • UI iOS
      • UI Android
Powered by GitBook
On this page
  • Add a TripListener
  • Get the trip response status (Deprecated)

Was this helpful?

Export as PDF
  1. Trip analysis
  2. iOS

TripListener

PreviousTrip managementNextCrash Detection

Last updated 4 months ago

Was this helpful?

The TripListener protocol provides useful information and events about trips analyzed by DriveKit.

For example, you can be informed when a trip analysis has started, finished, canceled, when a crash is detected, etc.

The trip recording lifecycle is exhaustively described in part.

Add a TripListener

func addTripListener(_ tripListener: TripListener)

You can remove a specific listener using the following method:

func removeTripListener(_ tripListener: TripListener)

To remove all TripListeners objects:

func removeAllTripListeners()

If you remove all your trip listeners or forget to add one, your app will not receive any feedback from the trip analysis module. It will not prevent the analysis from working but your code will not be able to execute its own logic (UI updates, notification, etc.).

Do not forget to remove your TripListener objects when you don't need it anymore.

TripListener interface includes several methods to implement:

Method
Description

tripRecordingStarted(state: DKTripRecordingStartedState)

Immediately called when a trip recording starts.

This callback is triggered:

  • after automatic trip detection.

tripRecordingConfirmed(state: DKTripRecordingConfirmedState)

tripRecordingCanceled(state: DKTripRecordingCanceledState)

Called when a trip recording is canceled. DKTripRecordingCanceledState indicates which event has canceled the trip.

tripRecordingFinished(state: DKTripRecordingFinishedState)

tripFinished(responseStatus: TripResponseStatus)

This method is called when a trip has been recorded by the SDK and analyzed by the DriveQuant's servers.

tripPoint(tripPoint: TripPoint)

tripSavedForRepost()

Called if at the end of the trip, the trip couldn't be sent to DriveQuant's server for the analysis, for example when the smartphone has no network. The trip is saved locally on the SDK and will automatically be sent later.

beaconDetected()

Called when a beacon sets in the SDK is detected.

significantLocationChangeDetected()

Called when a user significant location change is detected.

sdkStateChanged(state: State)

crashDetected(crashInfo: DKCrashInfo)

crashFeedbackSent(crashInfo: DKCrashInfo, feedbackType: DKCrashFeedbackType, severity: DKCrashFeedbackSeverity)

tripFinished(post: PostGeneric, response: PostGenericResponse)

This method is called when a trip has been recorded by the SDK and analyzed by the DriveQuant's servers.

End of trip notification: Depending on the trip analysis service's response in the tripFinished() callback, we recommend that you specify the notification content if you decide to display a user feedback:

  • For a vehicle trip, you can display a message such as: Your trip has been analyzed.

  • For a trip by rail it is better to display the following message: Your trip was made by train.

Get the trip response status (Deprecated)

This method has been deprecated and will be removed at the end of 2025.

Once the DriveQuant servers has analyzed a trip, the tripFinished() callback is triggered with the data in the PostGenericResponse object.

It can be useful to check the trip response status in order to check for example if the trip is valid or not with detailed information.

To do this, call the following method:

func getTripResponseStatus(_ tripResponse: PostGenericResponse) -> TripResponseStatus

after calling the DriveKit SDK's method.

DKTripRecordingStartedState object is described .

Called each time a trip is confirmed. DKTripRecordingConfirmedState object is described .

DKTripRecordingCanceledState object is described .

Called when trip recording has ended, before sending trip data to DriveQuant's servers. DKTripRecordingFinishedState object is described .

object contains the trip analysis made on DriveQuant's server.

Called when a trip is started and confirmed, for each GPS point recorded by the SDK. Data available in TripPoint object are described .

Called every time the state of the SDK changed with the new state as parameter. States are described .

Called when a crash event is detected. Triggered if Crash Detection is enabled. Read more

called when crash feedback is enabled and a confirmed crash is detected. Triggered if Crash Detection is enabled. Read more

tripStarted(startMode: StartMode) This method has been deprecated to be replaced by: tripRecordingConfirmed(state: DKTripRecordingConfirmedState)

Called each time a trip is started. StartMode indicates which event starts the trip. Possible values are described .

tripCancelled(cancelTrip: CancelTrip) This method has been deprecated to be replaced by: tripRecordingCanceled(state: DKTripRecordingCanceledState)

Called when a trip is cancelled. CancelTrip indicates which event cancels the trip. Possible values are described .

This method has been deprecated to be replaced by: tripFinished(responseStatus: TripResponseStatus)

PostGeneric object contains raw data sent to DriveQuant's server, PostGenericResponse object contains the trip analysis made on DriveQuant's server. Detailed description of these data are available .

The callback method tripFinished(post: PostGeneric, response: PostGenericResponse) is replaced by tripFinished(responseStatus: TripResponseStatus) which directly provides the useful information (see ).

The model is described in the References part.

Trip recording lifecycle
⚠️
⚠️
⚠️
here
here
TripResponseStatus
TripResponseStatus
here
here
here
here
TripResponseStatus
here
here
here
here
startTrip()
here