Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Issues accessing UserDefaults and performing API calls in CarPlay while iPhone is locked

I'm developing a CarPlay Fueling app with CarPlay entitlement properly configured. While testing, I ran into two issues and would appreciate any guidance:

  1. UserDefaults access while iPhone is locked:

In my CarPlay implementation, I read values from UserDefaults that were previously saved in the iOS app. However, when the iPhone is locked and the CarPlay session is active, it seems that the CarPlay extension cannot read the stored values. Is this the expected behavior? If so, how can I persist and access data across the app and CarPlay reliably?

  1. API calls while iPhone is locked:

The CarPlay interface in my app communicates with a server to display lists and detail views. When the iPhone is locked, are network calls still allowed from the CarPlay extension? Currently, I do not have any background modes enabled in the app capabilities. If I enable background modes and implement background network logic to ensure API calls complete properly, would this be considered acceptable usage for CarPlay in App Store review? Or could it raise any rejection concerns during the approval process?

Thanks in advance for your help.

Answered by Frameworks Engineer in 841538022

Hi,

CarPlay is part of your app, not an extension in your app. When your app is on the CarPlay screen, your app is considered foregrounded, as it has a scene that is in the foreground. You should be able to perform network calls and user defaults lookups as normal. If you're not seeing that behavior as expected, please file a feedback report. Thanks!

Accepted Answer

Hi,

CarPlay is part of your app, not an extension in your app. When your app is on the CarPlay screen, your app is considered foregrounded, as it has a scene that is in the foreground. You should be able to perform network calls and user defaults lookups as normal. If you're not seeing that behavior as expected, please file a feedback report. Thanks!

Data stored using UserDefaults should be available for apps in CarPlay while the iPhone is locked. However, other files stored using FileProtectionType complete or completeUnlessOpen may not be available to your app while the iPhone is locked.

Data stored using UserDefaults should be available for apps in CarPlay while the iPhone is locked.

This is generally true, however, the detail that easy to overlook is that the Default Data Protection Entitlement can override that by changing the protection level of the file used to store NSUserDefaults data. The end of this forum post has a more in depth description of that issue, however, the key point is that changing your Protection Entitlement setting will NOT resolve these issues, just make them more complicated.

You can find my advice for apps dealing with these issues here.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

Issues accessing UserDefaults and performing API calls in CarPlay while iPhone is locked
 
 
Q