Closed gavrichards closed 2 months ago
Hi @gavrichards - while adding CarPlay-support to my react native app (with push notifications support) I am now stuck at exactly this point. Did you manage to find a solution yet?
Hi, I have the same problem. After adding react-native-carplay, I can't get the launchOptions, so I can't find out exactly how the app was opened when using deepLink. I get userActivity in PhoneScene, but I don't know how to make this data reach the react application
@alex-vasylchenko check out @gavrichards implementation in https://github.com/birkir/react-native-carplay/issues/132#issuecomment-1655803813
He converts the connectionOptions
to launchOptions
which seems to work
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 My problem with carplay & scenes is that my RootComponent is rendered twice with scenes and navigation complays about linking setup called twice. Maybe you know how to avoid that?
@KestasVenslauskas I poured all the knowledge I gained into the stand-alone-example, especially into the README of the stand-alone-example.
The RootComponent being rendered twice sounds like your CarScene is still creating a second RootViewController
. Avoid this by following the setup outlined in the README (adjusted to the React Native version you're using).
@DanielKuhn Thank you so much! I just needed additional fix for handling deep links but the fix is mentioned here https://github.com/facebook/react-native/issues/35191#issuecomment-1333544005
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.
New Version
0.71.7
Old Version
0.70.8
Build Target(s)
iOS on iPhone in local development
Output of
react-native info
Issue and Reproduction Steps
I am attempting to upgrade React Native in my application from 0.70.x to 0.71.x. My app uses iOS Scenes, so that it can support CarPlay. Therefore I have previously converted AppDelegate to Swift and introduced PhoneScene and CarScene delegates. My app also has to handle receiving a URL from a push notification, and being launched via Siri Shortcuts with metadata.
For all of this to work, I had to move the setup of RCTBridge and RCTRootView to PhoneScene and CarScene (plus rootViewController and window to PhoneScene). This is because with Scenes
launchOptions
in AppDelegate is always empty. But traditionally that's where useful properties would be held from how the app was launched via a notification or Siri Shortcut. With Scenes, that data comes viaconnectionOptions
in each Scene delegate. But RCTBridge expects to receivelaunchOptions
, and they differ in format. Therefore I had to write something to convertlaunchOptions
intoconnectionOptions
, to pass to the bridge. Therefore the bridge and root view both have to be initiated in the Scene delegate, not AppDelegate. If those are initiated there, then rootViewController and window have to be too, as they use the bridge/root view. CarScene also therefore has to do the same as PhoneScene, just without initiating rootViewController and window, as they're not required for CarPlay.My app also uses react-native-bootsplash, and that has to be initiated after the rootView has been initiated, so therefore that has to happen in PhoneScene.
Here's the problem. With React Native 0.71, the initiation of RCTBridge, RCTRootView, rootViewController etc is all abstracted away to RCTAppDelegate, so there's no where for us to intervene and do what we’re doing for Scenes, passing launch/connectionOptions and initiating BootSplash.
With everything I've tried so far, I can get the app to build and launch on my device, but I just get a full black screen and can't get any further.
I would appreciate if anyone has any suggestions. I surely can't be the only developer who is using Scenes in their app and wants to use the latest version of React Native. Thanks!
What follows is how my AppDelegate and PhoneScene look before attempting the upgrade. This all works well.
AppDelegate
PhoneScene