- 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
-
Download Driving.xcframework and copy it into Frameworks directory in the project.
-
Update clientId in AppDelegate.swift in SygicDriving.initialize method. If you don't have your own clientId contact us
-
build and run
-
Install on device, put device in a car/bus/truck and take a test drive.
-
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
-
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)
-
Add both libraries (auth and driving) to the project and set embed and sign for them
-
Update clientId and license in AppDelegate.swift in SygicDriving.initialize method. If you don't have your own clientId and license contact us
-
build and run
-
Install on device, put device in a car/bus/truck and take a test drive.
-
Get client id and license from sygic. You will need those for initialization of library
-
Copy-paste new driving.xcframework to frameworks directory
-
Update SygicDriving.sharedInstance().initialize, now it is synchronous, with no online license checks. Library might be used in fully offline scenarios.
-
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?)
-
Validate that all your delegate function that are expected to be called are called. This is typical source of bugs.
-
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.
-
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.
-
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.
Library provides means to replay already driven trips again. Primary reason for this is testing.
What to do to enable replays:
- developer mode must be enabled
- go to the car and make some trips. With developer mode enabled all raw trip data are saved localy on the phone.
- 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.
- 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)
- 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)
}
}