xmtp / xmtp-react-native

A package you can use to build with XMTP in a React Native or Expo app.
MIT License
42 stars 20 forks source link

Custom Content Types #110

Closed nplasterer closed 11 months ago

nplasterer commented 1 year ago

It would be nice to be able to create custom content types in react native like we do in the other sdks.

dmccartney commented 1 year ago

High level, supporting custom content types in RN looks a little like this:

neekolas commented 1 year ago

I know there was a discussion about this earlier that I missed, but why not just ship bytes out of iOS/Kotlin and handle all encoding/decoding in JS?

dmccartney commented 1 year ago

I know there was a discussion about this earlier that I missed, but why not just ship bytes out of iOS/Kotlin and handle all encoding/decoding in JS?

The short answer is for performance. I sometimes forget that content types doesn't just mean "a little meta data on a reply" -- it also means large files with complicated encryption and rendering schemes.

Performance was the driving reason but I do think there's also an API/SDK design rationale that holds here too: react native is not a web context and developers are mislead trying to treat it that way. Native apps really do have fundamentally different architectures and expectations from web apps. The browser does a lot for you and your webpage doesn't run in your pocket. And IMO xmtp-js is actually better understood as xmtp-web-sdk -- it works great for web apps. But native app SDKs should feel different and be designed to support native UX flows (push notifs, auth, files, media playback, etc). Long term, this is why I think the RN SDK should be relatively easy to maintain as a wrapper on the iOS/Android SDKs (because they should have the same API).

nmalzieu commented 1 year ago

Totally agree! However I guess for "simple content types" that are basically some metadata, being able to code them in JS then use them in RN would be nice - and that would probably work as @neekolas said: just ship bytes out and do the work in JS. This might be subperformant in some cases but would make all content types available in RN which would also have great value - I guess that's exactly the goal of this task so we're on the right path!

nplasterer commented 11 months ago

Implemented in https://github.com/xmtp/xmtp-react-native/pull/155