birkir / react-native-carplay

CarPlay with React Native
https://birkir.dev/react-native-carplay/
MIT License
625 stars 103 forks source link

CarPlay app fails to load unless the app is already open on the mobile device #149

Open harrymash2006 opened 9 months ago

harrymash2006 commented 9 months ago

I am testing this on iOS simulator and also I tested the same on the real CarPlay in a car and the behaviour is same.

harrymash2006 commented 8 months ago

@DanielKuhn @birkir any clue about this?

DanielKuhn commented 8 months ago

My understanding is that react native always needs a native bridge to work. The bridge is usually created in the AppDelegate but when starting a CarPlay-app without launching the app first, you need to create the bridge in the CarScene. I pasted my native code in this issue. For my case it works for starting the app on CarPlay directly.

harrymash2006 commented 8 months ago

@DanielKuhn tried same scene files from podverse project but I am still getting the blank screen. I get this message in bundler Running "App" with {"rootTag":1,"initialProps":{}} in terminal but still it shows blank screen on CarPlay

DanielKuhn commented 8 months ago

Sorry, I'm at a loss here. My advice would be: Try stripping away all code that is unrelated to startup and add line-by-line debugging.

elieT27 commented 8 months ago

My understanding is that react native always needs a native bridge to work. The bridge is usually created in the AppDelegate but when starting a CarPlay-app without launching the app first, you need to create the bridge in the CarScene. I pasted my native code in this issue. For my case it works for starting the app on CarPlay directly.

Could someone maybe update de readm, so we can know that a bridge need to be created and how thank you

mursang commented 8 months ago

I got it working following this comment: https://github.com/birkir/react-native-carplay/issues/109#issuecomment-1344820783 (Changed swift code in my project to the one in the pull request)

Now Carplay can be opened without the need of the app. However, I'm facing a different issue with react native navigation that I still need to fix.

DanielKuhn commented 7 months ago

After fiddling around with this topic for quite some time now, always in doubt of what's happening under the hood and seeing ever more questions around starting on CarPlay without having the app running on phone, I took the liberty to create (and document!) an example app which runs independently of the phone app and supports launching on CarPlay directly (without having the phone app running) in this PR: https://github.com/birkir/react-native-carplay/pull/158 Patches welcome, feel free to add comments and improvements.

DanielKuhn commented 7 months ago

My understanding is that react native always needs a native bridge to work. The bridge is usually created in the AppDelegate but when starting a CarPlay-app without launching the app first, you need to create the bridge in the CarScene. I pasted my native code in this issue. For my case it works for starting the app on CarPlay directly.

Could someone maybe update de readm, so we can know that a bridge need to be created and how thank you

@elieT27 I added a description of my understanding of rootViewController, rootView and window creation in the README of my new example app