I built a desktop application with Electron JS, SQLite, and React JS.
The desktop app allows an admin to add, delete and retrieve clients and it's connected to a SQLite database that stores client information. It uses SQL queries to perform these operations:
//Add a client to the db
exports.addClient = (client) => {
db.prepare(
"INSERT INTO clients (name, phone , position, description) VALUES (?,?,?,?)"
).run(clients.name, clients.phone, clients.position, clients.description);
};
As you can see, I am not creating any REST APIs in here.
Now I want to build a mobile app but for the clients (with React Native), and it should be able to display clients information that are stored in the DB.
My question is how do I connect the mobile app to the database to fetch the data of clients? Do I write SQL queries like I did in the desktop app or do I have to create REST APIs and then fetch the data?
Mobile apps indeed use the same database(s) as a desktop app so that any changes in the database records whether on mobile or desktop is reflected on all connected devices.
For your problem (and correct me if I'm wrong), I believe you are try to connect a mobile app to a database hosted on the same machine as your desktop application. If so then you would need to create a connection to your database using a public ip address.
Here's a drawing
The downside to this method is that since your database will be publicly accessible, it will be vulnerable to a denial of service attacks, furthermore, your client(s) are talking to the database directly which makes scaling an issue. If you're not worried about these types of problems, or are creating doing this just for learning then I don't see any problem with directly connecting to the database.
With APIs, you can have a common interface for all your devices to interact with. Your desktop and mobile app can connect to the API and then the API can directly communicate with your database. This will allow you to move common CRUD functions from both your apps over to the API. It also makes scaling easier if your plan to add more devices in the future.
As for how to code data fetching function in react native, I think these posts might help:
Trying to fetch data from a remotely-hosted MySQL database, using React Native
https://dev.to/saulojoab/how-to-get-data-from-an-mysql-database-in-react-native-53a4
Related
I am looking for a way to create an app for an application I already have developed, and use it on Zoom.
So for example: I have a software application on my desktop that uses a GUI to communicate with SQL databases. It can add, update, and delete rows from the database.
What I am trying to accomplish is I want to create a Zoom app that allows me to connect that specific application, and with a single click of that icon, I can open up that software application.
I believe I found the right developing documentation: https://marketplace.zoom.us/develop/create#
but I don't know where to go from here. Should I be making a JWT, OAuth app, SDK, or a webhook-only app?
I am creating a react-native mobile app for a service that has to interact with the service's API to get and update data.
This service also has a web interface through which users can sign in and use the service (aka getting and updating data.
Since I am only developing the mobile applications, I have no access to the code on the web side of things and my only way to make changes to that code is to go through someone else.
From the resources available online, I feel like I should be able to make a mobile app that interacts with and updates data through the API, however my thought process for how I am going to handle a user updating data through the web interface and reflecting that in the app has hit a standstill.
Does anyone know of a term that I can use to describe this in such a way that I will likely find more results online (or even better, a react-native npm package that achieves this functionality)?
So far I have tried searching the following, but have found few results:
redux caching
handling data updated on the server redux
redux how to handle data changing on the server
how to handle database updates redux
Sockets.io seems like it would work for realtime updates.
Essentially, it works by shifting the connection from a request-based HTTP deal (where the client asks the server for stuff) to a websocket in which the client and server can send each other things (like database changes :D) over a constantly open stream, even if after a delay.
If I've Single API for Web and Mobile then how can accomplish following things.
1.In web I need to display 10 fields but in mobile may be 3 fields only ?
2.Basically we will have tight coupling on DB proc side as well if there is a change(Requirement) for WEB, then it could be hit Mobile as well ?
3.Testing -> May be lot of testing for all platforms ?
Simple solution is that you add a extra field into your API maybe call it channel, then use that channel field to indicate web or mobile channel.
Our Team is trying to build multiple Windows 8 Store Apps for an enterprise.
How do we maintain a common session for all apps(where we store data which need to be shared)?
How do we enable direct interaction between the apps developed i.e. sharing objects or string(JSON) among the apps?
There is not built in way to do this. Realistically you probably have three options to share data between applications.
The first is to use the cloud / web services. This makes the most sense as you'd have full control about what is shared, authentication etc. Using libraries such as SignalR could let you add real time functionality between the applications as well as multiple users.
The Share contract, by using custom data formats you could enable the apps to share specialised data between each of them. This can make sense if the user has a set of data they want to send to another application to enable a quick piece of workflow as the Share target is only partially launched. This also is limited in that it's enabled by user action.
Custom protocol handlers, by giving each app it's only protocol my-custom-app:///some-action?param1=value etc then you can pass data between apps, note this launches the app in question when you launch that uri. This would be best for more longer running scenarios.
I'd suggest a combination of all three depending on the user action. Cloud services to store the data for the user and then a mixture of Share and Protocol to enable to the user to smartly move the apps seamlessly.
Here exactly the same question as yours. In short: there is no such ability. Sometimes I think that it will be easier to share data via Internet that in device.
I'm developing an internal iOS cocoa app, in which multiple devices need to connect and read/write to a data connection. It will be similar to an inventory application.
Would this be best done using a server-side SQLLite communicator or some other kind of server-side data store? Or is there a method i don't know of that multiple devices can share data.
Any help is appreciated. Thanks.
A third-party service possibly worth checking out is Parse.
With Parse, you can add a scalable and powerful backend in minutes and launch a full-featured app in record time without ever worrying about server management. We offer push notifications, social integration, data storage, and the ability to add rich custom logic to your app’s backend with Cloud Code.
Depending upon the complexity and assuming that all devices can be connected to the same icloud account you could utliize icloud for this.
http://www.raywenderlich.com/6015/beginning-icloud-in-ios-5-tutorial-part-1