0

I would like to create a text only screen guiding users to configure the app on iPhone first, similar to "Unlock your iPhone to start CarPlay".

Screenshot of 'Unlock your iPhone to start CarPlay'

Other apps show (and I don't have screenshots) some info like "When it is safe, use your phone to set up your app".

By the docs, you only have a few templates available:

  • CPListTemplate
  • CPGridTemplate
  • CPTabBarTemplate
  • CPTemplate (which has this comment: You don’t use this class directly, or create your own subclasses. Instead, you must use one of the prebuilt templates, such as CPListTemplate or CPGridTemplate.)

But it seems that none of them could have only a text message.

Does anyone has created this kind of info message? I wanna show something when users haven't set their account yet.

Fernando M. Pinheiro
  • 610
  • 1
  • 10
  • 21

1 Answers1

0

I was able to show an info message (without tabs) this way:

    let infoTemplate = CPInformationTemplate(
      title: "",
      layout: .leading,
      items: [CPInformationItem(title: "", detail: "When it is safe, use your phone to set up your app".localized())],
      actions: []
    )
    interfaceController?.setRootTemplate(infoTemplate, animated: false)

Which renders as:

Screenshot in CarPlay emulator

Fernando M. Pinheiro
  • 610
  • 1
  • 10
  • 21
  • Have you tried the alert template? – fruitcoder Feb 28 '23 at 10:49
  • Yes, but it is not allowed: ` *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unsupported object passed to setRootTemplate:animated:completion:. Allowed classes: {( CPContactTemplate, CPTabBarTemplate, CPGridTemplate, CPMapTemplate, CPSearchTemplate, CPNowPlayingTemplate, CPPointOfInterestTemplate, CPListTemplate, CPInformationTemplate )}' ` – Fernando M. Pinheiro Mar 01 '23 at 12:52
  • Accordingly to the [docs](https://developer.apple.com/documentation/carplay/cpalerttemplate), `CPAlertTemplate` is a modal: _You must present alerts modally by calling the presentTemplate(_:animated:completion:) method available on your app’s instance of CPInterfaceController. The user dismisses the alert by pressing a button, or you can dismiss it by calling the interface controller’s dismissTemplate(animated:completion:) method._ – Fernando M. Pinheiro Mar 01 '23 at 12:53
  • Ah sorry, didn‘t know you wanted it as root – fruitcoder Mar 01 '23 at 20:03