Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Information if app is launched from CarPlay #195

Open
mefjuu opened this issue Jun 19, 2024 · 5 comments
Open

Information if app is launched from CarPlay #195

mefjuu opened this issue Jun 19, 2024 · 5 comments
Labels

Comments

@mefjuu
Copy link

mefjuu commented Jun 19, 2024

I wonder is there a way to obtain an info (e.g. in initialTags) if app is launched from CarPlay?
It would be useful to tune initialization logic up, e.g. to reduce startup time or get rid of SafeArea blocking children rendering in CarPlay problem (th3rdwave/react-native-safe-area-context#135)

@mefjuu mefjuu added the feature label Jun 19, 2024
@mefjuu mefjuu changed the title Information while app is launched from CarPlay Information if app is launched from CarPlay Jun 19, 2024
@DanielKuhn
Copy link
Contributor

When you set up your AppDelegate via initAppFromScene (see standalone-example) or similar you can simply pass arguments or flags to initAppFromScene from your CarScene and store them in the initialProps, which you can then access in react native.

@mefjuu
Copy link
Author

mefjuu commented Jun 20, 2024

@DanielKuhn I've just noticed it can be distinguished by concurrentRoot !== false initial prop when running on RN 0.74.x

 LOG  Running "MyApp" with {"rootTag":61,"initialProps":{"concurrentRoot":false}}
 LOG  Running "MyApp" with {"rootTag":71,"initialProps":{}}

while in repo's example app (not upgraded to the latest RN) initialProps are exactly the same

 LOG  Running "RNCarPlayScene" with {"rootTag":1,"initialProps":{}}
 LOG  Running "RNCarPlayScene" with {"rootTag":11,"initialProps":{}}

@DanielKuhn
Copy link
Contributor

If that's good enough for you, fine.
Just saying, though: If you need to be able to start your CarPlay app without the phone app running, you'll need to migrate to initAppFromScene sooner or later anyways

@mefjuu
Copy link
Author

mefjuu commented Jun 20, 2024

Ok, I've checked the linked PR. However, there any reason it hasn't been merged yet?
I'd like to use an "official" way of doing it though :)

@DanielKuhn
Copy link
Contributor

I guess you'll need to get used to the fact that there's no "official" way to integrate CarPlay into a react native app. The way an app is started natively from CarPlay results in native implementations of Scene and AppDelegates which always need to be adjusted to the react native version you're using in your app.
React Native will not support SceneDelegates (or Swift) any time soon: facebook/react-native#41777

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants