Get started
Prerequisite
Before starting DriveKit Driver Achievement integration, make sure that you have initialized DriveKit, especially if you have disable the SDK auto-initialization..
If you use DriveKit Driver Achievement without having initialized DriveKit, the SDK may not work properly in your application.
Integration
Get framework
DriveKit Driver Achievement SDK is available on CocoaPods master repo.
To access the framework in the repository, add the following lines to your Podfile:
Then, run pod install
.
Get Streaks
To get Driver streaks, you have to call the following method:
SynchronizationType
can have 2 values:
defaultSync
: if this value is used, the SDK will try to synchronize local trips with DriveQuant backend to get new streaks or modified streaks, and then return the streak list via the completionHandler.cache
: if this value is used, no synchronization will be performed and only streaks previously synchronized will be returned via the completionHandler.
StreakSyncStatus
in the completionHandler can have 4 values:
noError
: synchronization has been successfully performed.cacheDataOnly
: synchronizationType has been set to cache.failedToSyncStreakCacheOnly
: synchronization has failed, only streaks previously synchronized are returned.syncAlreadyInProgress
: a synchronization is in progress, only streaks previously synchronized are returned until the synchronization is finished.
Streak description
Streak themes description
The themes and conditions to increment the sequences of the trip are the following:
phoneDistraction
: the driver has not handled his phone.safety
: the safety score of the trip is higher or equal to 9.8.speeding
: the speeding score of the trip is higher or equal to 9.8.acceleration
: there wasn’t any harsh acceleration event during the trip.brake
: there wasn’t any hard braking event during the trip.adherence
: there wasn’t any adherence threshold crossing during the trip.call
: the driver has not made forbidden call during the trip.
Streak Result description
Get Badges
To get Driver badges, your have to call the following method:
SynchronizationType
can have 2 values:
defaultSync
: if this value is used, the SDK will try to synchronize local trips with DriveQuant backend to get new or updated badges, and then return the badge list via the completionHandler.cache
: If this value is used, no synchronization will be performed and only badges previously synchronized will be returned via the completionHandler.
BadgeSyncStatus
in the completionHandler can have 4 values:
noError
: Synchronization has been successfully performed.cacheDataOnly
: SynchronizationType has been set to cache.failedToSyncStreakCacheOnly
: Synchronization has failed, only badges previously synchronized are returned.syncAlreadyInProgress
: A synchronization is in progress, only badges previously synchronized are returned until the synchronization is finished.
Get badge statistics
It can be practical to get some badge statistics, like how many badges have been won and how many remain to be acquired. To get these information, call the following method:
DKBadgeStatistics
Badge description
DKBadge
DKBadgeCharacteristics
DKLevel
.bronze
.silver
.gold
DKBadgeCategory
.generic
.ecodriving
.safety
.phoneDistraction
Get ranking
To get driver’s Ranking, you need to call the following method of DriveKitDriverAchievement
class:
Ranking parameters
DKRankingType
The DKRankingType enum values are:
safety,
ecoDriving,
distraction,
speeding.
DKRankingPeriod
The DKRankingPeriod
enum values are:
weekly
: In the case of a weekly classification, the trips considered for the calculation of the user's position are those made between Monday midnight and Sunday midnight. If the user has not driven during the week, he is not ranked.monthly
: In the case of a monthly ranking, the trips considered for the calculation of the user's position are those made between the first and last day of the month.. If the user has not driven during this period, he is not ranked.allTime
: This ranking takes into account all of the driver's trips.
RankingSyncStatus
RankingSyncStatus
in the callback can have 5 values:
noError
: Synchronization has been successfully performed.cacheDataOnly
: SynchronizationType has been set to cache.failedToSyncRanking
: Synchronization has failed, only rankings previously synchronized are returned.syncAlreadyInProgress
: A synchronization is in progress, only rankings previously synchronized are returned until the synchronization is finished.userNotRanked
: The user is not ranked.
DKRanking Description
DKDriverRanked Description
Ranking access conditions
To enter a ranking, a driver must fulfill the following requirements:
Weekly ranking: 2 trips and 10 km since the first day of the week;
Monthly ranking: 5 trips and 20 km since the first day of the month;
Permanent ranking: 10 trips and 50 km since his first trip.
Data update
The scores, distances and ranks are updated every hour.
Last updated