Utilize the Driving Insights API

Accessing some of the API classes that are mentioned on this page requires additional Sentiance SDK dependencies. See this page for more information.

On this page, you can find examples of how to query the Sentiance SDK for driving insights, and how to register to receive real time driving insights in your app, for completed transports.

Query for Driving Insights

if let drivingInsights = Sentiance.shared.getDrivingInsights(forTransportId: transportId) {
    let event = drivingInsights.transportEvent
    let safetyScores = drivingInsights.safetyScores
    
    print("Focus score: \(safetyScores.focusScore ?? -1)")
    print("Legal score: \(safetyScores.legalScore ?? -1)")
    print("Smooth score: \(safetyScores.smoothScore ?? -1)")
    print("Call-while-moving score: \(safetyScores.callWhileMovingScore ?? -1)")
    print("Overall score: \(safetyScores.overallScore ?? -1)")

    print("Event ID: \(event.eventId)")
    print("Started on: \(event.startDate)")
    print("Ended on: \(String(describing: event.endDate))")
    print("Mode: \(event.transportMode)")

    if let distanceInMeters = event.distanceInMeters {
        print("Distance: \(distanceInMeters)")
    }

    print("Waypoints: \(event.waypoints)")
}

Subscribe for Driving Insights Updates

Query For Driving Events

Last updated