TripListener

The TripListener interface provides useful information and event about trips analyzed by DriveKit.

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

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 received 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:

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

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 to this, call the following method:

func getTripResponseStatus(_ tripResponse: PostGenericResponse) -> TripResponseStatus

The TripResponseStatus model is described in the References part.

Last updated