Carplay get stuck calling a webservice when iphone is locked

Hi,


I'm developing a CarPlay application and i''m having a problem getting data from a webservice. Basically I have two tabs, the first one is a list of media items that when an item is pressed, it starts playing an audio. The second tab is a list of itens that when pressed, a webservice is called and a new screen is pushed with a list of media itens returned from that service.


The problem is, when I test the app on the simulator everything works. It also works fine on my car IF my phone is unlocked. If i start carplay while the phone is locked, when I call a webservice the app just get stuck there and I get no response, as if i didn't have an internet connection. While it is in that state, if I unlock the phone I get a response immediately as if the app had internet connection again.


Another strange behaviour is, again, when the phone is locked and the app is stuck calling a webservice on the second tab, if i start playing any audio from the first tab, and then go back to the second tab, everything works fine again and I can call webservices again.


To sum up, I can only call a webservice and get a response successfully with carplay, if:

1. Device is unlocked on app start

2. I play an audio first, after the app is started with the iphone locked.


Is this an intended security measure that prevents internet connection if the phone is locked? Or is it a bug?


Thanks in advance.

Replies

+1 on this issue. I was getting similar replies from our users. As we don't have a Car Play unit available I can only rely on the simulator and occasional car share rides for testing.


What is strange is that on the simulator, even though the device is "locked", loading still seems to work fine.

I don’t support CarPlay myself, but my best guess as to what’s going on here is that your app is being suspended before the network request completes. Try using a

UIApplication
background task to prevent that and see what happens.

See my UIApplication Background Task Notes post for more info about this API.

As we don't have a Car Play unit available

Aftermarket CarPlay head units are not cheap [1], but neither is your time. This is the perfect opportunity for you to convince your boss that you need one.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

[1] Although they’re a lot cheaper than they used to be.