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

Support for ReactNative #9

Open
giautm opened this issue Jun 17, 2021 · 5 comments
Open

Support for ReactNative #9

giautm opened this issue Jun 17, 2021 · 5 comments

Comments

@giautm
Copy link

giautm commented Jun 17, 2021

Hi, thank you for build this library.

Currently, don't have any library good enough to use MQTT in ReactNative. Some libraries are using native libraries (Object-C/Java) to implement then wrap APIs in Javascript (MQTT over TCP: https://github.com/davesters/rn-native-mqtt). Some libraries are fork from the unmaintained library and didn't update anymore (MQTT over Websocket: https://github.com/rh389/react-native-paho-mqtt).

Until I found your work!

Support RN is simple, they have WebSocket API implement. Only a few things need to do, implement UTF Encoder/Decoder, and URL polyfill (whatwg-url-without-unicode)

@giautm
Copy link
Author

giautm commented Jun 22, 2021

Hi @jdiamond , any comment?

@jdiamond
Copy link
Owner

I'm open to it, but I don't have experience with React Native to really know what you need. Not sure if I would add a new build to the existing npm package or publish a new one?

@giautm
Copy link
Author

giautm commented Jun 22, 2021

Yes, I really have a working version here: https://github.com/giautm/mqtt-native/tree/main/src (Just for test).

ReactNative can compile typescript directly without bundle first.

I need to add import { URL } from 'react-native-url-polyfill' as first line in https://github.com/giautm/mqtt-native/blob/main/src/client/base_client.ts

And polyfill for TextEncoder/TextDecoder.

@jdiamond
Copy link
Owner

Thanks, I will study it this weekend.

@giautm
Copy link
Author

giautm commented Jun 24, 2021

Yeah, Your library working very well with ReactNative. I have a client that connects to a broker over 5 days without any interruption/disconnect. My application working stable for 5 days. 👍

But, I don't have any knowledge of the MQTT protocol. So I can't maintain it well, I can help to maintain a RN support package. :D

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

No branches or pull requests

2 participants