iOS

Get the framework

The Driver Achievement UI SDK is available on Cocoapods master repo.
To access the framework in the repository, add the following lines to your Podfile:
1
target 'my-target' do
2
pod 'DriveKitDriverAchievementUI'
3
end
Copied!
Then, run pod install.
On a Github repository, you also have a demo app and source code of Driver Achievement UI that you can use as an example.

Initialize

An initialization phase is required to use the feature included in the Driver Achievement UI SDK. In the application's AppDelegate file, import DriveKitDriverAchievementUI.
1
import DriveKitDriverAchievementUI
Copied!
Then, to initialize the Driver Achievement UI SDK in your app, you must call the initialization method in didFinishLaunchingWithOptions method of your AppDelegate.
1
import DriveKitCore
2
import DriveKitCommonUI
3
import DriveKitDriverAchievementUI
4
5
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
6
DriveKit.shared.initialize()
7
DriveKitUI.shared.initialize()
8
DriveKitDriverAchievementUI.shared.initialize()
9
...
10
}
Copied!

Override colors and texts

To override colors and texts in the Driver Achievement UI SDK, see Common UI configuration.

Select Streak themes

You can choose which streak theme you want to display in which order by calling the following method:
1
DriveKitDriverAchievementUI.shared.configureStreakThemes(streakThemes: [StreakDataType])
Copied!
Accepted values:
    .phoneDistraction
    .safety
    .acceleration
    .brake
    .adherence
    .speedLimits
Default value:
[.phoneDistraction, .safety, .acceleration, .brake, .adherence]
For speedLimits streaks, make sure that the service is activated on your DriveQuant account.

Select Badges categories

You can choose which badge category you want to display in which order by calling the following method:
1
DriverAchievementUI.shared.configureBadgeCategories(badgeCategories: [DKBadgeCatergory])
Copied!
Accepted values:
    .generic
    .ecodriving
    .safety
    .phoneDistraction
Default value:
[.generic, .ecodriving, .safety, .phoneDistraction]
Badges belonging to the generic category (.generic) are always displayed. It is not possible to hide these badges.

Select ranking themes

By calling the following method, you can choose which ranking types you want to display:
1
DriveKitDriverAchievementUI.shared.configureRankingTypes([DKRankingType])
Copied!
Accepted values:
    .ecodriving
    .safety
    .phoneDistraction
    .speeding
Default value:
[.safety, .ecoDriving, .distraction]

Set ranking selectors

This method allows you to change the displayed periods of ranking:
1
DriveKitDriverAchievementUI.shared.configureRankingSelector(DKRankingSelectorType)
Copied!
Accepted values:
    .none
    .period
Default value:.period(rankingPeriods: [.weekly, .monthly, .allTime])
If the DKRankingSelectorType ".none" is selected, the period “weekly” will be taken into consideration for rankings.

Configure ranking depth

This method allows you to choose the ranking depth you want to display:
1
DriveKitDriverAchievementUI.shared.configureRankingDepth(Int)
Copied!
Default value: 5
Accepted values: from 5 to 20
Last modified 11mo ago