I am building an android app using the ionicjs framework. I have done the basic layout using ionic's creator that gives me the code for it when I export it.
Now, I have to authenticate the login and register information against the details in the database, which is MongoDB. My question is, how do I install MongoDB? Do I install via the command prompt like it says in the Mongodb website or do a npm install in the root folder of my project?
After the installation, how do I go about connecting to the DB and doing the authentication? I think I need to use a REST API for that.
It would be very helpful if someone points me in a direction. I am new to developing apps like this.
Thanks!
MongoDb is a server-side database. So you have to install it on a remote machine, You shouldn't connect database directly with the mobile application which runs on clients hand. It's totally insecure, anyone can reveal your database connection information (password, username) by simply decompiling the app.
So, As you figure out, right way is to create a REST API to retrieve and send data back and forth between the server and the application.
Create a backend services with a server-side technology that your are prefer. It could be PHP,Python,Java or whatever. The client side application should not depend on the server-side technology your are using. Server side technology should completely transparent to the client application. You can attain this by designing good REST API.
Related
1) I have a web application. This web app is for a user to buy a point.
2) I have an android application for parking payment. Payment is based on point that user buy from the admin. Since I made two things which are web app for admin and android app for user, so I will have two database for each one right?
3) So, how can I transfer the point that user buy from the admin to an android application? Is this thing has to do with JSON fetch or pass data?
4) Basically I want the user to get the point from the web application? Your answer will be really helpful to me, thank you :)
The issue is design issue. Your mobile app and the web app don’t have to be two separate.
You can have one application with one database that both web and mobile point to.
If you’re using Android look into ionic framework that can help you code one codebase targeting both web and mobile.
See
https://ionicframework.com
https://scotch.io/tutorials/create-your-first-mobile-app-with-angularjs-and-ionic
You will have to build a single server for both your admin and your app. Both will have a single database that is controlled by your server. Your app will request the same server to redeem points and your admin will request the server to add points. You can use retrofit library in android for making api calls to your server
The web application and the android application must connect to the same database on the server. In the android application, to you get the data via json, you must use asynctask to download the server information or use libraries like Retrofit or volley that facilitate the handling of json.
I am trying to create an android application in which an user will pretty save some data in database-like user data, photos and also be able to retrieve.
But I am clueless how to set up a server, connect to some database etc.
Can somebody help me point to right resources for end-to-end installation of server, database, and its interaction with the android application
Just set up a basic server that works over HTTP, and use HTTP libraries for android to make requests and handle results in the device. There are plenty of technologies with which you could make the server, just google building REST API with PHP/.net/java (whichever language you are comfortable with).
If you are mobile app developer and want to create server-client app then better use any back-end service rather than implementing new by own. Some most advanced and simple to use services are Parse and Firebase , BaasBox also there are many more.
And the plus point is this services free of cost until you have very large users.
Maybe what I'm about to ask is stupid, generally I don't have so experience with server-side.
I'm building an Angular web application, with nodeJS on the server-side.
I need that the server (Node.exe) will installed in the device itself (IOS/Android), and nodeJS will open a localhost socket to communicate with the device.
(According to nodeJS official web site, nodeJS only support windows/Mac OS/Linux)
It's possible to do that?
If not, there is another server can I install in the device?
Yes you can with JXCore (a fork of nodejs), more info in this link
Build Mobile Apps with JavaScript and the Node.js Ecosystem repository is in here.
And how to compile it is in here JXCore - How to Compile
But if you need it to be nodejs (not the last version) you can use this link to do what you need Building and running Node.js for Android
UPDATED 27-09-2018
Like someone has pointed out, that project is no longer maintained but I have found and alternative by Using Termux on an Android phone you can use nodejs / gcc / vim / etc and more tools to do many thing
This link show how to do it for nodejs ( and I have tested it on my phone ):
Building a Node.js application on Android - Part 1: Termux, Vim and Node.js
First install termux from playstore, of course.
I don't understand the point of using a server tool on the client side.
If your application should work with an offline mode, you should put all data and other in your client app (using cordova).
If your application works with an online mode the server side is needed to serve your data. Here you can setup a nodeJS API which provides routes for your application to have content to print.
I'm not sure I brought you the wanted answer, so can explain more the point of using a server tool on a client device?
What you are trying to achieve, turns your device into a server.
A server side language is meant to stay on the server.
I don't really see why you need to open a localhost socket on the device to communicate with itself. Is it for offline testing? You can do that since you have a computer and a device, and both are connected to the same network.
I believe a really good start would be understanding the concept of the Client-Server architecture first.
But in short, the proper way of implementing a Client-Server app using your chosen technologies would be:
A server should provide the client with answers to his requests.
So in Node.js (server-side), write whatever you want to communicate with your database (Create, Read, Update, Delete), do custom processing, etc...
and return a structured answer.
The client is expecting answers to his requests, and is supposed to handle the answers in code. So the program written in AngularJS (which is your client-side language) will be installed on devices.
The client has to know the format of the server's answer. Is it plain text? XML? JSON? ...
so you mean you would like to have an app can run some services via http?
not sure if iOS allows application with JS virtual machine executing code ...
and for Android
searching on Github and I find how to build NodeJS for Android
https://github.com/dna2github/dna2oslab/tree/master/android/build
Here is an example to run compiled Nginx binary on Android at https://github.com/dna2github/dna2mtgol/tree/master/fileShare
You may modify a little more to replace Nginx to NodeJS. The code to run Nginx is not very nice; maybe you can try an Android Service to let the server run on backend on Android device.
Hope it is what you want.
I've built a Rails 4 web application with PostgreSQL database and hosted it on Heroku. The future plan for that database is to also be used by one Android application.
I am not completely sure how can I accomplish that. Do I need to build another REST application and host it on Heroku and somehow connect to the same database or there is another way?
How to connect with Android application to that database which is used by the web site? I know I can't connect directly.
Thank you for your guidance.
You don't need another app - just build an API for current one and then you can communicate from Android app to your web application (web app will connect to db and return data).
Have a look at Twitter API as example - you can access different resources and manage them via Twitter API
https://dev.twitter.com/docs/api/1.1
You can build something similar - create rails controllers that access your database and respond with structure you want - preferably JSON format of your models (or something custom if you need)
From Android app you can send request to your API and parse JSON responses - then process data your own way on Android app.
Don't forget about authentication between your Android app and web application - let only your Android app to use it.
I encourage you to browse internet for best practices 'How to create an API' :)
I'm trying to create a new android app from scratch and I'm trying to investigate on how to create a server backside that will support the following: oauth and sql.
I'm just a beginner and I don't familiar with building servers side for mobile app.
Is this the right flow to start building server-side for mobile app?
1) buy/register for some backside storage that will contain my code(EX. godaddy).
2) Install there SQL server and auth server(? - :( )
3) Install VS2010 and connect to the server
4) Start coding in PHP and deploy the code when I'm done.
Thank guys
Edit 1:
What do you say guys about http://www.ibm.com/developerworks/library/l-django/ ?
Take a look at parse.com They make backends for mobile super easy. I use them all the time.
I think you should take a look at this link:
http://android-developers.blogspot.de/2013/06/bootstrap-your-apps-cloud-services-with.html
Google is now offering a whole host of cloud backend stuff pretty much ready to work with mobile devices, and specially extra libraries ready to use on Android.
It's free to begin with and if your app works and start to have a lot traffic, then it starts to have some charges.
Further, it's mostly in Java already, so it's piece of cake for Android developer.