Greenbits is a company equipping stores with hardware and software to weight and sell their products. Our goal was to create a mobile application for Android tablets which can work as a station to weight products and print labels with QR code.
The major challenge with developing the app was to integrate the external hardware. There were a few basic requirements:
Another big problem to solve was to make application network issues resistant. It had to work in both online and offline environments. The requirements were as following:
To support the offline mode we had even more options. This happens to be a common problem, so there were many available solutions out there:
First of all, we had to deal with the hardware integration. We chose to use an existing third-party Java SDKs. We have created a Java module with standardized API which can be used in our React Native app. It allows to search devices via different connections, connect with detected devices and use it (for printing and reading weight). Source
After dealing with the hardware integration we started to think about the best solution for implementing an offline mode. We've decided to combine two different approaches together. We used Realm to store all important data. And we decided to synchronize it using WebSockets (in online mode) and also to fetch all data on every application launch and after going back online. This combined solution allowed us to be sure that the data in the application will always be up to date, even after a long period of being in an offline mode.
We also decided to queue every action when the app is in offline mode. We created a queue in Realm Database to allow case when a user does something in offline mode, then closes the app, opens it again and goes back to online mode. Every qued action should be called after that. We prepared this solution as a standalone offline library which can be used also in the other clients’ applications. The library allows to describe the shape of every data entity. There is also an option of configuring API endpoints for each data type and the behavior of WebSocket synchronization. Source
After months of developing we have managed to meet all requirements and this was the result of our work:
Need help with React or React Native? Let us know!