Contents

presentTemplate(_:animated:completion:)

Presents a template modally.

Declaration

func presentTemplate(_ templateToPresent: CPTemplate, animated: Bool, completion: ((Bool, (any Error)?) -> Void)? = nil)
func presentTemplate(_ templateToPresent: CPTemplate, animated: Bool) async throws -> Bool

Parameters

  • templateToPresent:

    The template to present modally.

  • animated:

    If True, CarPlay animates the presentation of the template.

  • completion:

    The closure CarPlay calls after it presents the template.

Discussion

CarPlay can only present one modal template at a time. templateToPresent must be one of CPActionSheetTemplate, CPAlertTemplate, or CPVoiceControlTemplate.

CarPlay calls completion after it presents the template. The Boolean parameter is true when the presentation succeeds; otherwise, it’s false and CarPlay provides an error that describes the failure. CarPlay throws an exception if the presentation fails and you don’t provide a closure.

See Also

Displaying Templates Modally