---
title: "pushTemplate(_:animated:completion:)"
framework: carplay
role: symbol
role_heading: Instance Method
path: "carplay/cpinterfacecontroller/pushtemplate(_:animated:completion:)"
---

# pushTemplate(_:animated:completion:)

Adds the specified template to the navigation hierarchy and displays it.

## Declaration

```swift
func pushTemplate(_ templateToPush: CPTemplate, animated: Bool, completion: ((Bool, (any Error)?) -> Void)? = nil)
```

```swift
func pushTemplate(_ templateToPush: CPTemplate, animated: Bool) async throws -> Bool
```

## Parameters

- `templateToPush`: The template to add to the navigation hierarchy.
- `animated`: If doc://com.apple.documentation/documentation/Swift/true, CarPlay animates the transition between templates.
- `completion`: The closure CarPlay calls after it adds the template.

## Discussion

Discussion important: You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration: func pushTemplate(_ templateToPush: CPTemplate, animated: Bool) async throws -> Bool For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously. The template you add becomes the topTemplate in the navigation hierarchy. CarPlay calls completion after it adds the template to the navigation hierarchy. The Boolean parameter is true when CarPlay adds the template successfully; otherwise, it’s false and CarPlay provides an error that describes the failure. CarPlay throws an exception if it can’t add the template and you don’t provide a closure.

## See Also

### Adding and Removing Templates

- [popTemplate(animated:completion:)](carplay/cpinterfacecontroller/poptemplate(animated:completion:).md)
- [popToRootTemplate(animated:completion:)](carplay/cpinterfacecontroller/poptoroottemplate(animated:completion:).md)
- [pop(to:animated:completion:)](carplay/cpinterfacecontroller/pop(to:animated:completion:).md)
