How to interop with native code?

What’s the story around interacting with native code?

  • My iOS app is using ApolloClient + interceptors to login and authenticate requests. How can I get that auth info into LiveView Native?
  • I use CLLocationManager to request location permission from the user. How can LiveView Native call out to a native function and handle a response? In ReactNative / Elm / Rescript the answer is to write some sort of bridge/port/binding that handles the interop.

Thanks!

For LiveView Native you will set auth through session store the same way you do in JS which means you are setting a cookie with your session information. Just like in a web LiveView app you submit the form and issue a redirect from the server. This will trigger an app reconnect which will make use of the cookie store along with the session information.

Ok, then for dropping LiveView Native into an existing app, I’d need to inject the token into the LiveView Native baseUrl, then handle that token on the Phoenix side? (Eg ElixirConfChat)

And for messages from Phoenix → Native, I’m guessing it’s the LiveView().onReceive(...? Do responses to onReceive get sent over to Phoenix?

Thanks!

It’s the same method as is used with Phoenix Auth