MQTT on React Native?
After really needing the react-native-mqtt to work and failing to configure it properly, alas, I have found react_native_mqtt. Yes, they look the same but trust me, they're different.
In this module you won't have to struggle with Podfiles (ios) or MainActivity.java or MainApplication.java (android) files to get this working. All you will need to do is include it.
and follow the instructions:
import { initMqtt } from 'react_native_mqtt';
import { AsyncStorage } from 'react-native';
... your awesome code below!
I did some research and it looks like the way to go is with native (tcp) mqtt, and not mqtt over websockets (eventhough you could do both).
The road was unpaved, so after looking into all of our options, I ended up modifying tuanpmt/react-native-mqtt in order to make the library more stable, and are now using it in production.
There you go: https://github.com/SudoPlz/sp-react-native-mqtt
That's native mqtt (using iOS and Android mqtt libraries) and not a websockets js library that needs weird configuration and imports to work with react-native. I'd say that's your best bet right now.
npm install sp-react-native-mqtt
and then follow the steps in readme to use it.
Try it.