I have a SwiftUI app - (https://youtu.be/VbAfUk_eYl0?si=JxUBh0Bpb-vc1E1U) - which I thought was almost ready for release - a manager for airdropped audio files from Logic Pro or other music creation applications. It uses AVAudioEngine and AVAudioPlayerNode to play audio, and the MediaPlayer API to integrate with car audio and similar, all of which works well.
It does not currently have an explicit CarPlay integration (and I'm slightly horrified at the amount of work that is going to require).
I had the good or bad luck of getting a loaner car with carplay while mine is being repaired yesterday, and lo and behold, when connected to the vehicle via CarPlay, there is no audio output in the vehicle at all. The now playing panel correctly shows the information my app provides about the currently playing song; the player node believes it is playing, the AVAudioSession is configured as it should be. But there is no sound.
Obviously I cannot ship it in this state.
I've tried fiddling with the parameters the AVAudioSession is configured with, in case there was some parameter that was preventing audio output, to no avail - currently:
var options = AVAudioSession.CategoryOptions()
options.insert(.allowAirPlay)
options.insert(.allowBluetooth)
options.insert(.allowBluetoothA2DP)
try session.setCategory(.playback, mode: .default, options: options)
try? session.setPreferredIOBufferDuration(0.002) // ~96 samples at 44.1kHz
try? session.setPrefersNoInterruptionsFromSystemAlerts(true)
try? session.setPrefersInterruptionOnRouteDisconnect(false)
try session.setActive(true, options: [.notifyOthersOnDeactivation])
All diagnostics within the app show the player operating correctly - files are played and flushed; AVAudioPlayerNodeCompletionCallbacks are called when they should be. But the output is not audible in the vehicle.
I would much prefer to ship this app without full-blown CarPlay integration, but with working audio when connected via CarPlay, and work on full CarPlay integration for the next release.
Is there some secret handshake I am just missing to make this work?
Posts under CarPlay tag
135 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
Hello all,
I have a food delivery app that I am beginning to implement CarPlay support in. Route picking, navigation, turn-by-turn guidance features all work perfectly on iPhone, and on CarPlay while the iPhone is unlocked, or locked but screen on.
However, when the iPhone is locked and the screen is off, the CarPlay map view stops following the user's location and appears to be frozen. When this happens, the other "map buttons" that are part of the CPMapTemplate continue to accept user input (I can enter and exit the map panning mode for example), the user's location continues to update, and the turn-by-turn guidance continues as normal. It appears to be just the map view (which is drawn on the window and is not part of the CPMapTemplate) that stops updating in this state.
I've been through every page of Apple documentation on CarPlay but nothing references or addresses how to keep the CarPlay session active while the iPhone is locked. I'm not sure where else to look for answers and I'm out of theories as to why this might happen.
Any guidance around this would be greatly appreciated.
Hello everyone, I'm developing a radio app and I want to add CarPlay. Before starting the program I requested all the necessary permissions and they were accepted. Now when I run the app, emulate CarPlay and try to access the app, it crashes and gives me this log:
*** Terminating app due to uncaught exception 'NSGenericException', reason: 'Application does not implement CarPlay template application lifecycle methods in its scene delegate.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001804b70ec __exceptionPreprocess + 172
1 libobjc.A.dylib 0x000000018008ede8 objc_exception_throw + 72
2 CoreFoundation 0x00000001804b6ffc -[NSException initWithCoder:] + 0
3 CarPlay 0x00000001bc830ee8 -[CPTemplateApplicationScene _deliverInterfaceControllerToDelegate] + 704
4 CarPlay 0x00000001bc82fa60 __64-[CPTemplateApplicationScene initWithSession:connectionOptions:]_block_invoke.4 + 116
5 CoreFoundation 0x00000001803e9aec CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER + 120
6 CoreFoundation 0x00000001803e9a24 ___CFXRegistrationPost_block_invoke + 84
7 CoreFoundation 0x00000001803e8f14 _CFXRegistrationPost + 404
8 CoreFoundation 0x00000001803e88f0 _CFXNotificationPost + 688
9 Foundation 0x0000000180ee2350 -[NSNotificationCenter postNotificationName:object:userInfo:] + 88
10 UIKitCore 0x0000000184f0a8e4 +[UIScene _sceneForFBSScene:create:withSession:connectionOptions:] + 1152
11 UIKitCore 0x0000000185aa445c -[UIApplication _connectUISceneFromFBSScene:transitionContext:] + 808
12 UIKitCore 0x0000000185aa470c -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 304
13 UIKitCore 0x0000000185573c08 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 260
14 FrontBoardServices 0x0000000187994ce4 __95-[FBSScene _callOutQueue_didCreateWithTransitionContext:alternativeCreationCallout:completion:]_block_invoke + 260
15 FrontBoardServices 0x00000001879950a4 -[FBSScene _callOutQueue_coalesceClientSettingsUpdates:] + 60
16 FrontBoardServices 0x0000000187994b64 -[FBSScene _callOutQueue_didCreateWithTransitionContext:alternativeCreationCallout:completion:] + 408
17 FrontBoardServices 0x00000001879c1d50 __93-[FBSWorkspaceScenesClient _callOutQueue_sendDidCreateForScene:transitionContext:completion:]_block_invoke.156 + 216
18 FrontBoardServices 0x00000001879a1618 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 160
19 FrontBoardServices 0x00000001879c0220 -[FBSWorkspaceScenesClient _callOutQueue_sendDidCreateForScene:transitionContext:completion:] + 388
20 libdispatch.dylib 0x0000000103e127b8 _dispatch_client_callout + 16
21 libdispatch.dylib 0x0000000103e163bc _dispatch_block_invoke_direct + 388
22 FrontBoardServices 0x00000001879e4b58 FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK + 44
23 FrontBoardServices 0x00000001879e4a34 -[FBSMainRunLoopSerialQueue _targetQueue_performNextIfPossible] + 196
24 FrontBoardServices 0x00000001879e4b8c -[FBSMainRunLoopSerialQueue _performNextFromRunLoopSource] + 24
25 CoreFoundation 0x000000018041b324 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 24
26 CoreFoundation 0x000000018041b26c __CFRunLoopDoSource0 + 172
27 CoreFoundation 0x000000018041a9d0 __CFRunLoopDoSources0 + 232
28 CoreFoundation 0x00000001804150b0 __CFRunLoopRun + 788
29 CoreFoundation 0x0000000180414960 CFRunLoopRunSpecific + 536
30 GraphicsServices 0x0000000190183b10 GSEventRunModal + 160
31 UIKitCore 0x0000000185aa2b40 -[UIApplication _run] + 796
32 UIKitCore 0x0000000185aa6d38 UIApplicationMain + 124
33 SwiftUI 0x00000001d1e2eab4 $s7SwiftUI17KitRendererCommon33_ACC2C5639A7D76F611E170E831FCA491LLys5NeverOyXlXpFAESpySpys4Int8VGSgGXEfU_ + 164
34 SwiftUI 0x00000001d1e2e7dc $s7SwiftUI6runAppys5NeverOxAA0D0RzlF + 84
35 SwiftUI 0x00000001d1b70c8c $s7SwiftUI3AppPAAE4mainyyFZ + 148
36 streamz.debug.dylib 0x0000000106148e98 $s7streamz7StreamzV5$mainyyFZ + 40
37 streamz.debug.dylib 0x0000000106148f48 __debug_main_executable_dylib_entry_point + 12
38 dyld 0x00000001032d9410 start_sim + 20
39 ??? 0x000000010301a274 0x0 + 4345406068
I also get this error in the 'App' protocol:
Thread 1: "Application does not implement CarPlay template application lifecycle methods in its scene delegate."
If you need anything specific to figure out what it's about, I'll be happy to help.
Hello,
I've been banging my head against this for a couple of days now
I can't get the CarPlay interface to work on my music app
I see the error: Application does not implement CarPlay template application lifecycle methods in its scene delegate
I've checked the sample code and developer guides and can't see my mistake
My CarPlay delegate code is:
class CarPlaySceneDelegate: UIResponder, CPTemplateApplicationSceneDelegate {
var interfaceController: CPInterfaceController?
var carPlayWindow: UIWindow?
private let playerManager = MusicPlayerManager.shared
private var playlists: MusicItemCollection<Playlist> = []
// MARK: - CPTemplateApplicationSceneDelegate Methods
func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene,
didConnect interfaceController: CPInterfaceController) {
// Store reference to the interface controller to use throughout the app
self.interfaceController = interfaceController
// Request Apple Music authorization if needed
requestMusicAuthorization()
// Configure the interface with the now playing template and specified tabs
setupCarPlayInterface(interfaceController)
}
func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene,
didDisconnectInterfaceController interfaceController: CPInterfaceController) {
// Clean up when CarPlay disconnects
self.interfaceController = nil
print("CarPlay disconnected")
}
func sceneDidBecomeActive(_ scene: UIScene) {
// Called when the scene has moved from an inactive state to an active state
print("CarPlay scene became active")
}
etc
My info.plist contains:
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<true/>
<key>UISceneConfigurations</key>
<dict>
<key>CPTemplateApplicationSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneClassName</key>
<string>CPTemplateApplicationScene</string>
<key>UISceneConfigurationName</key>
<string>TemplateSceneConfiguration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).CarPlaySceneDelegate</string>
</dict>
</array>
</dict>
</dict>
My one doubt is this entry in the plist: UISceneConfigurationName as I can't find any clarity in the docs how to use or implement this
Can anyone suggest where I need to be looking?
Thanks for your help!
iPhone:
iPhone 12 pro max, iOS:18.3.1
Step:
Connect CarPlay to my car, after connection success, CarPlay screen is black.
This issue only happens of first time connection;
I have asked OEM factory, they told me because of my iOS version is larger than 17.5, and above this version, will have this issue.
So, I need your help to figure problem and update in new version.
We are experiencing an issue where our app gets stuck during launch. The splash screen appears for some time, and then the app either becomes unresponsive or closes unexpectedly. However, there are no crash logs captured in Xcode or Firebase Crashlytics, indicating that the app is not crashing but rather being terminated. This issue is preventing affected users from properly launching the app.
Additionally, some users have reported occasional lag and slow performance when using the app. The issue occurs only for a specific subset of users and appears to be related to other Electronic Logging Device (ELD) apps running in the background. When these apps are active, our app struggles to launch and sometimes becomes unresponsive.
We suspect that this behavior could be related to system resource allocation, such as high memory consumption by background apps, which might be affecting our app's ability to launch correctly. However, we have been unable to reproduce the issue on our end despite multiple attempts.
Actions Performed During App Launch:
Firebase configuration
API requests, including:
Fetching account details
Registering the FCM token with the server
Asynchronous background requests to fetch POI details
Creating a local database and storing POI data in local storage
We would like guidance from Apple regarding potential causes and debugging strategies, especially in scenarios where the app does not produce crash logs but still fails to launch properly. Any insights into memory management, conflicts with background applications, or system resource constraints would be highly appreciated.
Steps to Reproduce:
Install and launch the app on an affected device.
Observe that the app gets stuck on the launch screen.
After some time, the app terminates unexpectedly.
Issue is inconsistent and occurs only for certain users.
Presence of other ELD apps running in the background appears to influence the issue.
With CarPlay communication plugin R18.1, I followed these steps to integrate Enhance siri, the music sound was output from carplay and there is no option for output to Car.
============================================
Enhanced Siri
Declare supported audioFormats for the AuxIn and AuxOut streams
Since the AuxIn and AuxOut streams for Siri do not have to be both active at the same time, the accessory must claim audio formats support
for AuxIn Audio and AuxOut audio independently. The audio formats for each stream can differ from each other (48KHz for AuxOut and 16KHz
for AuxIn). The new audio types represent these new streams - AuxIn/speechRecognition & AuxOut/speechRecognition.
Check if connected device supports the feature
AirPlayReceiverSessionHasFeatureEnhancedSiri()
Claim support in the Setup Response message if device supports the feature
Add kAirPlayKeyAccessoryEnabledFeature_EnhancedSiri key through the AirPlayReceiverServer delegate AirPlayReceiverServerCopyProperty_f
function for the kAirPlayKey_AccessoryEnabledFeatures key.
Helper function: CFArrayAppendValue()
Add Enhanced Siri parameters dictionary in the INFO message
Add dictionary through the AirPlayReceiverServer delegate AirPlayReceiverServerCopyProperty_f
function for the kAirPlayKey_EnhancedSiriInfo key.
kAirPlayKey_EnhancedSiriInfo dictionary parameters:
Voice activation of Siri - kAirPlayKey_EnhancedSiriVoice
Current language of voice model - kAirPlayKey_VoiceModelCurrentLanguage
Supported languages of voice model - kAirPlayKey_VoiceModelSupportedLanguages
Enhanced Button activation of Siri - kAirPlayKey_EnhancedSiriButton
Supported zone(s) if any - kAirPlayKey_SupportedSiriTriggerZones
Update AudioStream
Get state of the AuxIn state by providing an implementation of AudioStreamUpdateState() - Off, local buffering, or streaming to device.
Decouple input streams from output streams. AuxIn is an independent input stream only. The property kAudioStreamProperty_Direction will
provide the necessary information if the stream is input, output or input & output.
Provide a handler for the AirPlayReceiverSessionDelegate setEnhancedSiriParams_f
This will provide additional information:
Activation type
Setting the language of the voice model
Invoke the Communication Plugin to start buffering
Once the activation type has been specified, the accessory can request the plugin to start buffering using
AirPlayReceiverSessionAuxInStart().
Use the new APIs to trigger Siri:
AirPlayReceiverSessionRequestSiriActionWithLatency()
AirPlayReceiverSessionRequestSiriVoiceActivationWithLatency()
AirPlayReceiverSessionRequestSiriVoiceActivationWithSample()
Button presses and voice activations should use this new APIs which adds a timestamp of the activation. These APIs allow
a choice of a latency or a sample for button and voice activations.
If there is a delay between the user pressing the button to notifying the device on the button press, this latency value
should represent this time.
If the accessory can determine which zone activated, it can provide the zone with the request.
Invoke the Communication Plugin to stop buffering
You may need to invoke the plugin to stop buffering (AirPlayReceiverSessionAuxInStop()) if exclusive access to the microphone is necessary.
Such instances may include but not limited to:
Native voice recognition session
Telephony
Another stream function which uses the microphone starts
modesChanged notification can be used to determine if a resource is being used
Note, if the session ends, the plugin will automatically stop buffering
Why is there no option as a CarPlay developer to enable the creation of an App to track and enter your car's maintenance records? I know the pat reply would be Apple doesn't want you to do this while car is in motion. But I would normally do this while parked at the dealership or other service provider no?
I'm working on adding CarPlay support to an audio app and I'd like to mimic the behavior of the Apple Music app on launch.
Forgive me, but I think using Gherkin syntax here will help to best describe the desired behavior:
GIVEN the Apple Music app is in a cold state (not launched or in memory)
AND another audio app is actively playing audio
WHEN I launch the Apple Music app from CarPlay
THEN the Now Playing template is shown via a push
AND the appropriate Now Playing info is shown
AND the Now Playing button is shown on the tab bar
AND the actively playing audio from another audio app is NOT interrupted
The current behavior I see in my own app is that I can push on the Now Playing template and fill out the MPNowPlayingInfoCenter's info dictionary, but it won't render the info or show the Now Playing button on the tab bar until I start playing audio.
Also, is there a way to hide the Now Playing button after the queue of content has finished playing? I'm able to pop the Now Playing template, but the Now Playing button is still present and tapping it will navigate the user to the now blank Now Playing template.
I am currently implementing multiple scenes in my React Native / Swift application (one scene for the phone and one scene for CarPlay). I am facing an issue where one scene renders completely white (on the iPhone) but I can see in the console that the code is running (for example if I add a console.log to the App.tsx I can see that console log happen in XCode).
There are no errors when building the app in XCode, and testing with the simulator CarPlay appears to render the correct output, but there is no component being rendered on the simulated phone screen (just white).
AppDelegate.swift
import CarPlay
import React
import React_RCTAppDelegate
import ReactAppDependencyProvider
import UIKit
@main
class AppDelegate: RCTAppDelegate {
var rootView: UIView?;
static var shared: AppDelegate { return UIApplication.shared.delegate as! AppDelegate }
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
self.moduleName = "appName"
self.dependencyProvider = RCTAppDependencyProvider()
self.initialProps = [:]
self.rootView = self.createRootView(
with: RCTBridge(
delegate: self,
launchOptions: launchOptions
),
moduleName: self.moduleName!,
initProps: self.initialProps!
);
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
override func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
if (connectingSceneSession.role == UISceneSession.Role.carTemplateApplication) {
let scene = UISceneConfiguration(name: "CarPlay", sessionRole: connectingSceneSession.role)
scene.delegateClass = CarSceneDelegate.self
return scene
}
let scene = UISceneConfiguration(name: "Phone", sessionRole: connectingSceneSession.role)
scene.delegateClass = PhoneSceneDelegate.self
return scene
}
override func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {}
override func sourceURL(for bridge: RCTBridge) -> URL? {
self.bundleURL()
}
override func bundleURL() -> URL? {
#if DEBUG
RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
#else
Bundle.main.url(forResource: "main", withExtension: "jsbundle")
#endif
}
}
PhoneSceneDelegate.swift
import Foundation
import UIKit
import SwiftUI
class PhoneSceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?;
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
if session.role != .windowApplication {
return
}
guard let appDelegate = (UIApplication.shared.delegate as? AppDelegate) else {
return
}
guard let windowScene = (scene as? UIWindowScene) else {
return
}
let rootViewController = UIViewController()
rootViewController.view = appDelegate.rootView;
let window = UIWindow(windowScene: windowScene)
window.rootViewController = rootViewController
self.window = window
window.makeKeyAndVisible()
}
}
App.tsx
import React, {useEffect, useState} from 'react';
import type {PropsWithChildren} from 'react';
import {CarPlay, ListTemplate} from 'react-native-carplay';
import {
ScrollView,
StatusBar,
StyleSheet,
Text,
useColorScheme,
View,
} from 'react-native';
import {
Colors,
DebugInstructions,
Header,
LearnMoreLinks,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
type SectionProps = PropsWithChildren<{
title: string;
}>;
function Section({children, title}: SectionProps): React.JSX.Element {
const isDarkMode = useColorScheme() === 'dark';
return (
<View style={styles.sectionContainer}>
<Text
style={[
styles.sectionTitle,
{
color: isDarkMode ? Colors.white : Colors.black,
},
]}>
{title}
</Text>
<Text
style={[
styles.sectionDescription,
{
color: isDarkMode ? Colors.light : Colors.dark,
},
]}>
{children}
</Text>
</View>
);
}
function App(): any { // React.JSX.Element
const isDarkMode = useColorScheme() === 'dark';
const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};
const [carPlayConnected, setCarPlayConnected] = useState(CarPlay.connected);
useEffect(() => {
function onConnect() {
setCarPlayConnected(true);
CarPlay.setRootTemplate(new ListTemplate(/** This renders fine on the CarPlay side */));
}
function onDisconnect() {
setCarPlayConnected(false);
}
CarPlay.registerOnConnect(onConnect);
CarPlay.registerOnDisconnect(onDisconnect);
return () => {
CarPlay.unregisterOnConnect(onConnect);
CarPlay.unregisterOnDisconnect(onDisconnect);
};
});
if (carPlayConnected) {
console.log('car play connected');
} else {
console.log('car play not connected');
}
const safePadding = '5%';
// This doesn't render on the phone?
return (
<View style={backgroundStyle}>
<StatusBar
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
backgroundColor={backgroundStyle.backgroundColor}
/>
<ScrollView
style={backgroundStyle}>
<View style={{paddingRight: safePadding}}>
<Header/>
</View>
<View
style={{
backgroundColor: isDarkMode ? Colors.black : Colors.white,
paddingHorizontal: safePadding,
paddingBottom: safePadding,
}}>
<Section title="Step One">
Edit <Text style={styles.highlight}>App.tsx</Text> to change this
screen and then come back to see your edits.
</Section>
<Section title="See Your Changes">
<ReloadInstructions />
</Section>
<Section title="Debug">
<DebugInstructions />
</Section>
<Section title="Learn More">
Read the docs to discover what to do next:
</Section>
<LearnMoreLinks />
</View>
</ScrollView>
</View>
);
}
const styles = StyleSheet.create({
sectionContainer: {
marginTop: 32,
paddingHorizontal: 24,
},
sectionTitle: {
fontSize: 24,
fontWeight: '600',
},
sectionDescription: {
marginTop: 8,
fontSize: 18,
fontWeight: '400',
},
highlight: {
fontWeight: '700',
},
});
export default App;
I have been attempting to get this working now for some 20+ hours with no luck with searching for answers elsewhere. I am very new to building apps with React Native and Swift so could do with some support.
Is there anyway I can customize Carplay template look like this
Hi there, I'm facing an issue when disconnecting CarPlay that the navigation session seems to be in some weird state where it is not properly finished. So when I reconnect CarPlay the "Metadata in instrument cluster or HUD" does not update anymore until I start another navigation session and stop that one.
You can see that the instruction to the left on this screen recording is not updating anymore after a reconnect.
https://www.youtube.com/watch?v=sncxyJULjQk
I have a modified the CostalRoad sample app to add support for the HUD cluster and to auto start a navigation simulation when CarPlay connects.
https://github.com/g4rb4g3/CoastalRoads
Can anyone tell me what I have to do when CarPlay disconnect so I can start a new navigation session on reconnect that has a working HUD cluster?
Fun fact is that Apple Maps handles this quite nice (https://www.youtube.com/watch?v=OpJEIyGcwdo), it somehow manages to finish the navigation session and brings up the HUD cluster just fine on reconnect.
I wonder how I can achieve the same, anyone having an idea on that?
When are you guys going to fix the CarPlay issues with this new update? I use this for work and it’s really an issue. Nothing is working and it takes up entirely too much space.
Is there any way I can get updates when I change CarPlay style settings?
I've tried CPSessionConfigurationDelegate.contentStyleChanged and CPTemplateApplicationSceneDelegate.contentStyleDidChange, but they always produce the same result.
When I choose:
Automatic -> I receive light in case of daylight;
Always Dark and Always Show Dark Map toggle on -> dark
Always Dark and Always Show Dark Map toggle off -> light.
But it seems to be wrong, b/c CarPlay's toolbar is still dark, and I receive light.
Is there a way to get a dark style when choosing Always Dark and Always Show Dark Map toggle off? Or at least get updates when the Always Show Dark Map toggle changes?
Hello,
I have a CarPlay Navigation app and utilize the AVSpeechSynthesizer to speak directions to a user. Everything works great on my CarPlay simulator as well as when plugged into my GMC truck. However, I found out yesterday that one of my users with a Ford truck the audio would cut in an out.
After much troubleshooting, I was able to replicate this on my own truck when using Bluetooth to connect to CarPlay. My user was also utilizing Bluetooth. Has anyone else experienced this? Is there a fix to the problem?
import SwiftUI
import AVFoundation
class TextToSpeechService: NSObject, ObservableObject, AVSpeechSynthesizerDelegate {
private var speechSynthesizer = AVSpeechSynthesizer()
static let shared = TextToSpeechService()
override init() {
super.init()
speechSynthesizer.delegate = self
}
func configureAudioSession() {
speechSynthesizer.delegate = self
do {
try AVAudioSession.sharedInstance().setCategory(.playback, mode: .voicePrompt, options: [.mixWithOthers, .allowBluetooth])
} catch {
print("Failed to set audio session category: \(error.localizedDescription)")
}
}
func speak(_ text: String) {
Task(priority: .high) {
let speechUtterance = AVSpeechUtterance(string: text)
speechUtterance.voice = AVSpeechSynthesisVoice(language: AVSpeechSynthesisVoice.currentLanguageCode())
try AVAudioSession.sharedInstance().setActive(true, options: .notifyOthersOnDeactivation)
speechSynthesizer.speak(speechUtterance)
}
}
func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer, didFinish utterance: AVSpeechUtterance) {
Task {
stopSpeech()
try AVAudioSession.sharedInstance().setActive(false)
}
}
func stopSpeech() {
speechSynthesizer.stopSpeaking(at: .immediate)
}
}
right now it looks like the app type must follow the guidelines like Messenger app, Navigate app, and Music app only. What about the Automotive app itself, What is the flexibility of it?
We have an app for service cars for one brand (officially)(car users around 1m+). but we looking to merge the experience between outside the car and inside the car. Can we top up some features on the app to share some information that is a part of the car like trip calculation or car info display on the screen? or services time to notice them?
And following that question can we know about the exact spot or brief from Apple car play for now and next-gen?
Or can we work with your team closely as a partner? to make things happen and develop it to be a flagship product, we can share some data and talk about it with real insight.
Hi you all,
I wrote an CarPlay Driving Task App that can start Navigation to a well defined target. This works as expected (navigation app is started to the destination), but sometime, for any important reason, my application receives updates about current destination. I should interrupt current navigation to current destination and update to the new destination. I'm not able to interrnupt/update. Have you any idea if this is possible?
Thanls in advance!
Hello everyone,
I am currently working on an app project aimed at users who want to quickly and easily capture their ideas and notes while on the go. The basic concept is to develop an iOS app where users can store both typed notes and voice recordings – essentially a "brain dump" solution. The core functionality (storing, editing, synchronizing via CloudKit, etc.) will be handled within the iOS app.
In addition, I plan to integrate a CarPlay extension that allows the driver to start and stop a recording – ideally through a minimalist interface featuring a large record button and a "Done" button. Since the iPhone is often not within immediate reach in the car, the CarPlay integration should serve as a quick trigger to initiate the recording in the iOS app.
My questions are as follows:
Has anyone had experience implementing a CarPlay extension for an app that primarily handles notes and voice recordings, rather than falling into the traditional categories like navigation, audio, or communication?
Has such a concept ever been approved by Apple, or are there known hurdles and guidelines that must be observed?
Are there alternative approaches to implementing CarPlay integration in this context in a compliant and effective manner?
I would greatly appreciate any feedback, shared experiences, and tips on best practices.
Thank you in advance and best regards!
Hello,
Could you please help me with the below,
How to display a toast message to the user in CarPlay after a successful operation?
How to show a spinner or an activity indicator just before performing some operation?
I have referred to the CarPlay pdf design guidelines in which I couldn't find support for the above two. But I could see a loader within a button in one of the default apps in CarPlay simulator.
Kindly help me with these queries
Hi all!
Based on documentation: https://developer.apple.com/documentation/carplay/cplistitem/handler
If you need to perform asynchronous tasks, dispatch them to a background queue and call the completion closure or completionBlock when they complete.
In a normal case, it works perfectly. But, if it takes "too much", for example, 10 seconds (streaming with retries, app business logic), when I call the "completionBlock" inside "handler" doesn't do anything.
Exists a timeout in "completionBlock"?
Thanks!