---
title: CPNavigationAlert
framework: carplay
role: symbol
role_heading: Class
path: carplay/cpnavigationalert
---

# CPNavigationAlert

An alert that displays map- or navigation-related information to the user.

## Declaration

```swift
@MainActor class CPNavigationAlert
```

## Overview

Overview To display a navigation alert, create an instance of CPNavigationAlert and pass it to the map template’s present(navigationAlert:animated:) method. When creating an alert, you must provide a title, action, and duration. The duration tells the system how long to show the alert before automatically dismissing it. You can also include a subtitle and secondary action when needed. The system displays the primary and secondary actions as buttons on the alert. After the user taps the button, the system calls the action’s handler block, which is where your app performs the requested action. The system also dismisses the alert after the user taps the button. However, your app can dismiss the alert without any user interaction by calling dismissNavigationAlert(animated:completion:).

## Topics

### Creating a Navigation Alert

- [init(titleVariants:subtitleVariants:image:primaryAction:secondaryAction:duration:)](carplay/cpnavigationalert/init(titlevariants:subtitlevariants:image:primaryaction:secondaryaction:duration:).md)
- [init(titleVariants:subtitleVariants:imageSet:primaryAction:secondaryAction:duration:)](carplay/cpnavigationalert/init(titlevariants:subtitlevariants:imageset:primaryaction:secondaryaction:duration:).md)

### Getting Titles

- [titleVariants](carplay/cpnavigationalert/titlevariants.md)
- [subtitleVariants](carplay/cpnavigationalert/subtitlevariants.md)
- [updateTitleVariants(_:subtitleVariants:)](carplay/cpnavigationalert/updatetitlevariants(_:subtitlevariants:).md)

### Getting the Alert Image

- [image](carplay/cpnavigationalert/image.md)
- [imageSet](carplay/cpnavigationalert/imageset.md)

### Getting the Actions

- [primaryAction](carplay/cpnavigationalert/primaryaction.md)
- [secondaryAction](carplay/cpnavigationalert/secondaryaction.md)

### Getting the Alert Duration

- [duration](carplay/cpnavigationalert/duration.md)
- [CPNavigationAlertMinimumDuration](carplay/cpnavigationalertminimumduration.md)

### Enumerations

- [CPNavigationAlert.DismissalContext](carplay/cpnavigationalert/dismissalcontext.md)

### Initializers

- [init(coder:)](carplay/cpnavigationalert/init(coder:).md)
- [init(titleVariants:subtitleVariants:avatarImage:alert:actions:duration:)](carplay/cpnavigationalert/init(titlevariants:subtitlevariants:avatarimage:alert:actions:duration:).md)
- [init(titleVariants:subtitleVariants:avatarImage:alertImage:actions:duration:)](carplay/cpnavigationalert/init(titlevariants:subtitlevariants:avatarimage:alertimage:actions:duration:).md)

### Instance Properties

- [actions](carplay/cpnavigationalert/actions.md)
- [alertImage](carplay/cpnavigationalert/alertimage.md)
- [avatarImage](carplay/cpnavigationalert/avatarimage.md)

### Instance Methods

- [updateTitleVariants(_:subtitleVariants:avatarImage:alert:actions:duration:)](carplay/cpnavigationalert/updatetitlevariants(_:subtitlevariants:avatarimage:alert:actions:duration:).md)

### Type Properties

- [maximumActionsCount](carplay/cpnavigationalert/maximumactionscount.md)
- [maximumAlertImageSize](carplay/cpnavigationalert/maximumalertimagesize.md)
- [maximumAvatarImageSize](carplay/cpnavigationalert/maximumavatarimagesize.md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)
- [Sendable](swift/sendable.md)

## See Also

### Displaying a Navigation Alert

- [present(navigationAlert:animated:)](carplay/cpmaptemplate/present(navigationalert:animated:).md)
- [dismissNavigationAlert(animated:completion:)](carplay/cpmaptemplate/dismissnavigationalert(animated:completion:).md)
- [currentNavigationAlert](carplay/cpmaptemplate/currentnavigationalert.md)
