# iOS

## Get the framework

To add the Driver Achievement UI module to your app using **Swift Package Manager**, add `DriveKitDriverAchievementUI` from repository: `https://github.com/DriveQuantPublic/drivekit-ui-ios.git` as dependency.

{% hint style="info" %}
On this[ Github repository](https://github.com/DriveQuantPublic/drivekit-ui-ios), you also have a demo app and source code of Driver Achievement UI that you can use as an example.
{% endhint %}

## Initialize

If you have [disabled the SDK auto-initialization](/get-started-drivekit/ios/advanced-configurations.md#manually-initialize-the-sdk), the Driver Achievement UI module must also be manually initialized. In the application's AppDelegate file, import `DriveKitDriverAchievementUI`.

```swift
import DriveKitDriverAchievementUI
```

**‌**Then, to initialize the Driver Achievement UI SDK in your app, you must call the initialization method in `didFinishLaunchingWithOptions` method of your AppDelegate.

```swift
import DriveKitCore
import DriveKitCommonUI
import DriveKitDriverAchievementUI

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
   DriveKit.shared.initialize()
   DriveKitUI.shared.initialize()
   DriveKitDriverAchievementUI.shared.initialize()
   ...   
}
```

## Override colors and texts

To override colors and texts in the Driver Achievement UI SDK, see [Common UI configuration](/common-ui/ios/get-started.md).

## Select Streak themes

You can choose which streak theme you want to display in which order by calling the following method:

```swift
DriveKitDriverAchievementUI.shared.configureStreakThemes(streakThemes: [StreakDataType])
```

Accepted values:

* `.phoneDistraction`
* `.safety`
* `.acceleration`
* `.brake`
* `.adherence`
* `.speedLimits`
* `.call`

Default value:

&#x20;`[.phoneDistraction, .safety, .acceleration, .brake, .adherence, .call]`

{% hint style="danger" %}
For speedLimits streaks, make sure that the service is activated on your DriveQuant account.
{% endhint %}

## Display streak list interface

To get the streak list view controller, you can call the following method:

```swift
DriveKitDriverAchievementUI.shared.getStreakViewController()
```

## Select Badges categories

You can choose which badge category you want to display in which order by calling the following method:

```swift
DriverAchievementUI.shared.configureBadgeCategories(badgeCategories: [DKBadgeCatergory])
```

Accepted values:

* `.generic`
* `.ecodriving`
* `.safety`
* `.phoneDistraction`

Default value:

\[`.generic`, `.ecodriving`, `.safety`, `.phoneDistraction`]<br>

{% hint style="info" %}
Badges belonging to the generic category (.generic) are always displayed. It is not possible to hide these badges.
{% endhint %}

## Display Badge list interface

To show the badges list view controller, you can use the following method:

```swift
DriveKitDriverAchievementUI.shared.getBadgesViewController()
```

## Select ranking themes

By calling the following method, you can choose which ranking types you want to display:

```swift
DriveKitDriverAchievementUI.shared.configureRankingTypes([DKRankingType])
```

Accepted values:

* `.ecodriving`
* `.safety`
* `.distraction`
* `.speeding`

Default value:

\[`.safety`, `.ecoDriving`, `.distraction`]

## **Set ranking selectors**

This method allows you to change the displayed periods of ranking:

```swift
DriveKitDriverAchievementUI.shared.configureRankingSelector(DKRankingSelectorType)
```

Accepted values:

* `.none`
* `.period`

Default value:`.period(rankingPeriods: [.weekly, .monthly, .allTime])`

{% hint style="info" %}
If the `DKRankingSelectorType` **"**`.none"` is selected, the period “weekly” will be taken into consideration for rankings.
{% endhint %}

## **Configure ranking depth**

This method allows you to choose the ranking depth you want to display:

```swift
DriveKitDriverAchievementUI.shared.configureRankingDepth(Int)
```

Default value: 5

Accepted values: from 5 to 20

## Display Ranking interface

To display the ranking view controller, you can call the following method:

```swift
DriveKitDriverAchievementUI.shared.getRankingViewController()
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.drivequant.com/driver-achievement/user-interface/ios.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
