Skip to content

Sygic/driving-example-ios

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 

Repository files navigation

driving-example-ios

  • Updated for driving library 2.x
  • If you need to access example app for 1.x fetch code from master, tag example-1.x or use branch example-1.x

Instructions for driving 1.x:

  1. Download Driving.xcframework and copy it into Frameworks directory in the project.

  2. Update clientId in AppDelegate.swift in SygicDriving.initialize method. If you don't have your own clientId contact us

  3. build and run

  4. Install on device, put device in a car/bus/truck and take a test drive.

Instructions for driving 2.x:

  1. Download Driving.xcframework Driving.xcframework and copy it into Frameworks directory in the project. You have to use version 2.x, best option is the latest 2.x

  2. Download SygicAuth.xcframework Lib and copy it into Frameworks directory in the project. Use the latest library version (1.3 at the time of writing this text)

  3. Add both libraries (auth and driving) to the project and set embed and sign for them

  4. Update clientId and license in AppDelegate.swift in SygicDriving.initialize method. If you don't have your own clientId and license contact us

  5. build and run

  6. Install on device, put device in a car/bus/truck and take a test drive.

Upgrading from 1.x?

  1. Get client id and license from sygic. You will need those for initialization of library

  2. Copy-paste new driving.xcframework to frameworks directory

  3. Update SygicDriving.sharedInstance().initialize, now it is synchronous, with no online license checks. Library might be used in fully offline scenarios.

  4. Delegate methods that are using timestamp as Double were removed. Use the ones with Date. Example: func driving(_ driving: SygicDriving, tripDidStart timestamp: Double, location: CLLocation?) -> func driving(_ driving: SygicDriving, tripDidStart date: Date, location: CLLocation?)

  5. Validate that all your delegate function that are expected to be called are called. This is typical source of bugs.

  6. Driving 2.x added few new functionalities that change the way trip is reported. One most notable example is that trip may now include segments of walking and driving.

  7. Event TripDidEnd and TripDiscarted are exclusive to each other. You only get one of those, not both. When trip is discarted don't expect that finalTripData is called, nor tripModelChanged. So it is important to handle both.

Notes

  • it is recommended to use one Sygic Auth object for all instances of sygic libraries that require Sygic Auth. For example: Driving lib with combination of Sygic Maps. During configuration you need to pass Auth object.

  • all API methods available in Driving 1.x were removed from library version 2.x. API access is delivered as separate package.

Simulation of trips without driving

Library provides means to replay already driven trips again. Primary reason for this is testing.

What to do to enable replays:

  1. developer mode must be enabled
  2. go to the car and make some trips. With developer mode enabled all raw trip data are saved localy on the phone.
  3. Now you phone has the data that are required for replays. It is possible to copy app data from the phone and put them in the simulator.
  4. To start replay use
SygicDriving.sharedInstance().replayTrip(at: index)

where index is index of the trip in the local trip list. To get list of all trips use these methods:

let tripCount = SygicDriving.sharedInstance().tripCount()

Reduced data about the trip:

let tripData = SygicDriving.sharedInstance().tripMeta(at: indexPath.row)

You can remove trip using:

SygicDriving.sharedInstance().removeTrip(at: indexPath.row)

To show complete trip data from local trip data use:

let tripData = SygicDriving.sharedInstance().trip(at: tripIndex)
  1. To stop replay use
SygicDriving.sharedInstance().stopReplay()

Typical usage is to use these methods with UITableView similar to this:

override func numberOfSections(in tableView: UITableView) -> Int {
    return 1
}

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return  SygicDriving.sharedInstance().tripCount()
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "tripsListCell", for: indexPath) as! TripListCell
    let tripData = SygicDriving.sharedInstance().tripMeta(at: indexPath.row)
    if let tripData = tripData {
        cell.configureWith(startDate: tripData.tripStartDate, endDate: tripData.tripEndDate, startReason: tripData.tripStartReason, endReason: tripData.tripEndReason, uploadDate: tripData.tripLastUploadDate, tripId: tripData.tripServerId, httpCode: tripData.tripUploadHttpErrorCode, retryCount: tripData.tripUploadRetryCount)
    }
    return cell
}

override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
    return true
}

override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
    if editingStyle == .delete {
        SygicDriving.sharedInstance().removeTrip(at: indexPath.row)
        tableView.deleteRows(at: [indexPath], with: .fade)
    }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published