birkir / react-native-carplay

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

Initialization constraint - start the app from car #96

Closed vladamx closed 2 years ago

vladamx commented 2 years ago

When i start carplay app from a car screen i get the black screen because i haven't started the app on the phone first. If i start the app on the phone first and then in the car - everything works fine. From the architecture standpoint it makes sense since data and controler logic is on JS side.

But for me this is a deal breaker for mixing RN and Carplay.

Is there any workaround this? Do i get this right? @birkir

ouabing commented 2 years ago

Just encounter the same problem. I found if you initialize the RN bridge and rootView in didFinishLaunchingWithOptions, the top level JS code will execute. If your CarPlay app does not heavily depend on the JS logics inside your RN views, you can try initialize the CarPlay app in the top level.

vladamx commented 2 years ago

Unfortunately, I need to use scenes api for initialization

image
ouabing commented 2 years ago

I'm also using scenes. Do you initialize your rctRootView in AppDelegate? If so I believe your top level JS code will execute.

vladamx commented 2 years ago

I do but my carplay window is not initialized since phone scene has not run in the case when i am only running carplay window

vladamx commented 2 years ago

Can you share your AppDelegate, Phone delegate and Carplay delegate?

vladamx commented 2 years ago

Solved it - i was trying to show splash screen in app delegate which breakes the app when launched from carplay screen only and fails silently.

@ouabing Thank you

vladamx commented 2 years ago

@ouabing Does your global js app logic run when you are using CarPlay but your phone screen is off?

ouabing commented 2 years ago

@vladamx yes, but the component you register to AppRegistry will not render until you start the app

vladamx commented 1 year ago

Timers do not work when screen is off. So, if you are doing any debouncing on JS side, you need to move it to native.