4 Replies
      Latest reply on Dec 18, 2019 10:30 PM by shibin2k17
      StijnSpijker-Flitsmeister Level 1 Level 1 (0 points)

        We're integrating the CarPlay framework in our navigation app, and so far, we absolutely love it!

         

        We are currently using a CPSearchTemplate so a user can search for a destinations to navigate to.

        The Apple Maps CarPlay app show the user a Siri screen first, where it is possible to use voice to search for destinations (and it's possible to use a keyboard by pressing the keyboard icon). We would love this integration in our app too!

         

        Is this currently possible?

         

        We already support the Speech framework for recognizing Speech and are using that to search for destinations. We found the CPVoiceControlTemplate in documentation, which suggests it is possible to use the Siri/Speech framework:

         

        CarPlay navigation apps must show the voice control template during audio input.

        However, when we create this template (with or without "voiceControlStates") and push it, the app receives a SIGABRT without clear error messages (crashes in the main.swift). The crash happens exactly on/after a push.

         

        interfaceController?.pushTemplate(voiceControlTemplate, animated: true)

         

        libc++abi.dylib: terminating with uncaught exception of type NSException

         

        Can anyone shine a light on this for us?

        • Re: How to use CPVoiceControlTemplate?
          Rico-Apple-DTS Apple Staff Apple Staff (170 points)

          Are you trying to add a Siri style search experience to your main app or are you having trouble integrating CPSearchTemplate into your CarPlay interface?

            • Re: How to use CPVoiceControlTemplate?
              StijnSpijker-Flitsmeister Level 1 Level 1 (0 points)

              We're trying to integrate the CPSearchTemplate into our CarPlay interface. We have a working CarPlay implementation (viewController + templates) but when we try to push this template the app just crashes.

              Do you have more info on how to create / push / implement it?

               

              Thnx!

               

              Example implementation in our code:

               

              enum VoiceControlStates: String {
                  case loading = "loading"
                  case listening = "listening"
                  case recognized = "recognized"
              }
              
              let vct = CPVoiceControlTemplate(voiceControlStates: [
                  CPVoiceControlState(identifier: VoiceControlStates.loading.rawValue, titleVariants: ["loading"], image: nil, repeats: true),
                  CPVoiceControlState(identifier: VoiceControlStates.listening.rawValue, titleVariants: ["listening"], image: nil, repeats: true),
                  CPVoiceControlState(identifier: VoiceControlStates.recognized.rawValue, titleVariants: ["recognized"], image: nil, repeats: true)
              ])
              CPBaseController.sharedInstance.interfaceController?.pushTemplate(vct, animated: true)

              Crash:

               

              0   CoreFoundation                    0x1e873bef8 __exceptionPreprocess + 228
              1   libobjc.A.dylib                   0x1e7909a40 objc_exception_throw + 55
              2   CoreFoundation                    0x1e8640ac4 +[NSException raise:format:] + 115
              3   CarPlay                           0x2125a7944 CPAssertAllowedClasses + 159
              4   CarPlay                           0x2125a79c4 -[CPInterfaceController pushTemplate:animated:] + 83
              5   Flitsmeister                      0x100bfe700 closure #1 in static FMCPMapTemplate.installMapButtons(template:) + 8349440 (FMCPMapTemplate.swift:53)
              6   Flitsmeister                      0x100c005dc thunk for @escaping @callee_guaranteed (@guaranteed CPMapButton) -> () + 8357340 (:0)
              7   CarPlay                           0x2125a57fc -[CPMapButton handlePrimaryAction] + 91
              8   CarPlay                           0x2125b5b8c __50-[CPMapTemplate handleActionForControlIdentifier:]_block_invoke + 687
              9   libdispatch.dylib                 0x1e81736c8 _dispatch_call_block_and_release + 23
              10  libdispatch.dylib                 0x1e8174484 _dispatch_client_callout + 15
              11  libdispatch.dylib                 0x1e81209ec _dispatch_main_queue_callback_4CF$VARIANT$mp + 1067
              12  CoreFoundation                    0x1e86ca1bc __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 11
              13  CoreFoundation                    0x1e86c5084 __CFRunLoopRun + 1963
              14  CoreFoundation                    0x1e86c45b8 CFRunLoopRunSpecific + 435
              15  GraphicsServices                  0x1ea938584 GSEventRunModal + 99
              16  UIKitCore                         0x215540bc8 UIApplicationMain + 211
              17  Flitsmeister                      0x100424418 main + 115736 (main.m:36)
              18  libdyld.dylib                     0x1e8184b94 start + 3
            • Re: How to use CPVoiceControlTemplate?
              shibin2k17 Level 1 Level 1 (0 points)

              I’m facing some issues with implementing CPVoiceControlTemplate, In carPlay voice control, we need to implement Siri Intents  ??

              or its like CPGridTemplate ??

              hoping that anyone here can give me some idea to break this issue.
              Thank you...