> For the complete documentation index, see [llms.txt](https://docs.mapbox.com/android/ja/navigation/llms.txt)

# Get started

> **Note (warning): Experimental API**
> 
> The **Driver Notifications API** is in a preview state and has a high chance of being changed in the future.

This guide covers the most important steps to get started using the **Driver Notifications API**, with code snippets to help you start your implementation.

### 1. Configure credentials and set up repositories

For detailed instructions on configuring credentials, refer to the [Get started](https://docs.mapbox.com/android/ja/navigation/guides/install/) page, and for guidance on initializing the SDK entry point, see the SDK [Initialization guide](https://docs.mapbox.com/android/ja/navigation/guides/initialization/).

### 2. Add the dependency

Add the library dependency to your `build.gradle`. The library version matches Navigation SDK version, they have the same release cadence. This way, you should not worry about version compatibility.

```kotlin
dependencies {
  implementation "com.mapbox.navigationcore:driver-notification:3.29.0"
}
```

### 3. Instantiate and start `DriverNotificationManager`

```kotlin
val driverNotificationManagerOptions = DriverNotificationManagerOptions.Builder().build()
val driverNotificationManager = DriverNotificationManager(driverNotificationManagerOptions)
driverNotificationManager.start()
```

[`DriverNotificationManagerOptions`](https://docs.mapbox.com/android/navigation/api/coreframework/3.29.0/driver-notification/com.mapbox.navigation.driver.notification/-driver-notification-manager-options/) is optional and can be omitted.

### 4. Add notification provider

Add one of the exposed providers that implements [`DriverNotificationProvider`](https://docs.mapbox.com/android/navigation/api/coreframework/3.29.0/driver-notification/com.mapbox.navigation.driver.notification/-driver-notification-provider/), such as [`SlowTrafficNotificationProvider`](https://docs.mapbox.com/android/navigation/api/coreframework/3.29.0/driver-notification/com.mapbox.navigation.driver.notification.traffic/-slow-traffic-notification-provider/).

```kotlin
val slowTrafficNotificationProvider = SlowTrafficNotificationProvider()
driverNotificationManager.attachDriverNotificationProvider(slowTrafficNotificationProvider)
```

### 5. Observe notifications with `DriverNotificationManager` instance

Use the before created instance of [`DriverNotificationManager`](https://docs.mapbox.com/android/navigation/api/coreframework/3.29.0/driver-notification/com.mapbox.navigation.driver.notification/-driver-notification-manager/) to observe [`DriverNotification`](https://docs.mapbox.com/android/navigation/api/coreframework/3.29.0/driver-notification/com.mapbox.navigation.driver.notification/-driver-notification/). All attached notification providers generate notifications that inherit from [`DriverNotification`](https://docs.mapbox.com/android/navigation/api/coreframework/3.29.0/driver-notification/com.mapbox.navigation.driver.notification/-driver-notification/). Check the type to retrieve the details of the notification.

```kotlin
driverNotificationManager.observeDriverNotifications().collect { notification ->
    when(notification) {
        is SlowTrafficNotification -> handleSlowTrafficNotification(notification)
        else -> handleOtherNotifications(notification)
    }
}
```

### 6. Detach notifications provider from `DriverNotificationManager` instance

If you no longer need to receive a specific notification type, detach the before created [`DriverNotificationProvider`](https://docs.mapbox.com/android/navigation/api/coreframework/3.29.0/driver-notification/com.mapbox.navigation.driver.notification/-driver-notification-provider/) instance from [`DriverNotificationManager`](https://docs.mapbox.com/android/navigation/api/coreframework/3.29.0/driver-notification/com.mapbox.navigation.driver.notification/-driver-notification-manager/).

```kotlin
driverNotificationManager.detachDriverNotificationProvider(slowTrafficNotificationProvider)
```

### 7. Stop `DriverNotificationManager` instance

Stop [`DriverNotificationManager`](https://docs.mapbox.com/android/navigation/api/coreframework/3.29.0/driver-notification/com.mapbox.navigation.driver.notification/-driver-notification-manager/) instance when notifications are no longer required. For example, stop it if a user disables this feature in the application settings.

```kotlin
driverNotificationManager.stop()
```