Before starting DriveKit Driver Achievement integration, make sure that you have initialized DriveKit.
Get framework from Github.
To add the Driver Achievement SDK module to your app, add the following line to your dependencies in your application build.gradle file:
dependencies {implementation 'com.drivequant.drivekit:drivekit-driver-achievement:1.8.0'}
To get Driver streaks, you have to call the following method:
DriveKitDriverAchievement.getStreaks(listener: StreaksQueryListener,type: SynchronizationType = SynchronizationType.DEFAULT)
DriveKitDriverAchievement.INSTANCE.getStreaks(StreaksQueryListener listener, SynchronizationType type)
SynchronizationType
can have 2 values:
DEFAULT
: if this value is used, the SDK will try to synchronize local trips with DriveQuant backend to get new trips or modified trips, and then return the trip list via the callback.
CACHE
: If this value is used, no synchronization will be performed and only trips previously synchronized will be returned via the callback.
StreakSyncStatus
in the callback can have 3 values:
NO_ERROR
: synchronization has been successfully performed.
CACHE_DATA_ONLY
: synchronizationType has been set to cache.
FAILD_TO_SYNC_STREAKS_CACHE_ONLY
: synchronization has failed, only streaks previously synchronized are returned.
Attribute | Type | Description |
| StreakTheme | Streak Theme identifier |
| StreakResult | Current streak result |
| StreakResult | Best streak result |
The themes and conditions to increment the sequences of the trip are the following:
PHONE_DISTRACTION
: 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 thresold crossing during the trip.
Attribute | Type | Description |
| Double | Total distance travelled during streak |
| Double | Total duration travelled during streak |
| Int | Number of trips performed within streak |
| Date | Date of the first trip of the streak |
| Date | Date of the last trip of the streak |
To get Driver badges, you have to call the following method:
DriveKitDriverAchievement.getBadges(listener: BadgesQueryListener,synchronizationType: SynchronizationType = SynchronizationType.DEFAULT)
DriveKitDriverAchievement.INSTANCE.getBadges(listener: BadgesQueryListener,synchronizationType: SynchronizationType = SynchronizationType.DEFAULT)
BadgeSyncStatus
in the callback can have 3 values:
NO_ERROR
: Synchronization has been successfully performed
.CACHE_DATA_ONLY
: SynchronizationType has been set to cache.
FAILD_TO_SYNC_BADGES_CACHE_ONLY
: Synchronization has failed, only badges previously synchronized are returned.
If you want to notify users when they acquired a new set of badge you can get this value from the callback.
Attribute | Type | Description |
| String | Badge theme identifier |
| BadgeCategory | Badge category |
| List<BadgeCharacteristics> | Badge properties |
Attribute | Type | Description |
| Level | Badge level |
| String | Badge name |
| String | Badge icon name (for a won badge) |
| String | Badge default icon name (for a pending badge) |
| String | Clé localisable correspondant à la description pour l’affichage dans l'application. |
| String | Badge progress message |
| Double | Distance or number of trips performed |
| String | Badge congratulations message |
| Int | Distance or number of trips required to win the badge |
The Level
enum values are:
BRONZE
SILVER
GOLD
The BadgeCategory enum values are:
GENERIC
SAFETY
ECO_DRIVING
PHONE_DISTRACTION
To get driver’s ranking, you need to call the following method:
DriveKitDriverAchievement.getRanking(rankingType: RankingType,listener: RankingQueryListener,rankingDepth: Int = 5,rankingPeriod: RankingPeriod = RankingPeriod.WEEKLY,synchronizationType: SynchronizationType = SynchronizationType.DEFAULT)
DriveKitDriverAchievement.INSTANCE.getRanking(RankingType rankingType,RankingQueryListener listener,int rankingDepth,RankingPeriod rankingPeriod,SynchronizationType synchronizationType)
Attribute | Type | Description |
| RankingPeriod | Period of the ranking |
| int | Number of participants in the ranking higher and lower than the current user. It could be between 5 and 20. |
| RankingType | Is the theme of the leaderboard. |
| SynchronizationType | Whether data are fetch locally or from server. |
The RankingPeriod enum values are:
WEEKLY
: is the period from the last Monday at midnight to the next Sunday at midnight.
MONTHLY
: is the period from the 1rst day of the month (at midnight) to the last (at midnight).
ALL_TIME
: is the period since the creation of the app.
The RankingType enum values are:
SAFETY,
DISTRACTION,
ECO-DRIVING,
SPEEDING.
RankingSyncStatus
in the callback can have 3 values:
Synchronization status:
NO_ERROR
: Synchronization has been successfully performed.
CACHE_DATA_ONLY
: SynchronizationType has been set to cache.
FAILD_TO_SYNC_RANKINGS_CACHE_ONLY
: Synchronization has failed, only rankings previously synchronized are returned.
USER_NOT_RANKED
: Driver not ranked.
Attribute | Type | Description |
| String | Theme of the ranking |
| String | Period of the ranking |
| String | Ranking group name |
| Int | Position of the driver in the DriverRanked list |
| Int | Previous driver’s rank |
| List<DriverRanked> | List of the rated drivers |
| Int | Total number of rated drivers |
Attribute | Type | Description |
| String | Unique identifier of the driver |
| String | Driver’s nickname |
| Int | Driver’s rank in the leaderboard. This value is determined from the score rounded to 2 decimal places. If there is a tie, the one who has travelled the most distance is first. |
| Double | Driver’s score (according to the theme). This is the average of scores of the trips made in the period under consideration. |
| Double | Covered distance by the driver in the specified period in km. |
To enter a ranking, a driver must have at least one scored trip in the ranking period.
The scores, distances and ranks are updated every hour.
If you need to reset Driver Achievement configuration (user logout, clear data for example), you can call the following method:
DriveKitDriverAchievement.reset()
DriveKitDriverAchievement.INSTANCE.reset()
All data saved locally by the Driver Achievement SDK will be erased and default configuration will be restored.