birkir / react-native-carplay

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

CarPlay.onConnect not producing any result #150

Closed shubhadeep-foodhub closed 8 months ago

shubhadeep-foodhub commented 8 months ago

I am trying to test the possibility of this library in our existing app.

as we are still supporting iOS 13, I am trying to use the 1.3.1 version of this library and following the steps written in the readme and examples associated with it. for testing, I am using iPhone 15 simulator and car play simulator. but in the below code, CarPlay.onConnect is not producing any results and the app is not showing in the simulator. can anyone please let me know what I am doing wrong?

useEffect(() => {
        const helloWorld = new GridTemplate({
          buttons: [],
          title: 'Hello world',
        });

        CarPlay.onConnect(() => {
          console.log('connected to carplay');
        })
        CarPlay.onDisconnect(() => {
          console.log('disconnected to carplay');
        })

        CarPlay.setRootTemplate(helloWorld);
      }, []);
elieT27 commented 8 months ago

I am experiencing the same issue, I am myself using the the latest version of you library. I followed the readme, but without any result, I am not seeing my app in the simulator and I cannot connect to carPlay. Any clue ?

shubhadeep-foodhub commented 8 months ago

I am not able to find any solutions till now. can anyone help with some proper/latest steps? @birkir @DanielKuhn

DanielKuhn commented 8 months ago

I don't have any experience with older versions of this package, so I'm unable to help here. Using the current example works fine for me:

const [carPlayConnected, setCarPlayConnected] = useState(CarPlay.connected);

useEffect(() => {
  function onConnect() {
    setCarPlayConnected(true);
  }

  function onDisconnect() {
    setCarPlayConnected(false);
  }

  CarPlay.registerOnConnect(onConnect);
  CarPlay.registerOnDisconnect(onDisconnect);

  return () => {
    CarPlay.unregisterOnConnect(onConnect);
    CarPlay.unregisterOnDisconnect(onDisconnect);
  };
});
shubhadeep-foodhub commented 8 months ago

@DanielKuhn Thanks for the reply. Can you please let me know whether I test this using a carplay simulator and an iPhone simulator as I don't have an iPhone. Are there any other steps other than the readme? actually, the app is not showing on the carplay simulator.

DanielKuhn commented 8 months ago

@shubhadeep-foodhub run your app on Simulator.app, open a CarPlay window (via I/O > External Displays) and launch the app there. Once the app opens on CarPlay the onConnect method is called. If your app doesn't show up at all in the CarPlay window, then you probably haven't set an entitlement in Xcode, indicating that your app supports CarPlay.

shubhadeep-foodhub commented 8 months ago

@DanielKuhn Thank you for the support. The App is running properly after setting the proper path in Code Signing Entitlements.

claus-lysholm commented 8 months ago

Aahh, will try the Entitlements tip and then update my posted issue 🤞