Apple swift - How can an app connect to existing heroku/S3 database - ios

Im new to iOS and new to SWIFT with no previous experience with Obj-C. But, Im not new to Ruby. I have a web based app on heroku and am beginning to learn SWIFT so I can build an iOS counterpart. I need to wrap my head around the bigger picture before I can get started and I can not figure out how these apps connect to databases.
Can an iOS app connect to an S3 database...and share that database with a website? Is there documentation on this process that I have over looked.

Connecting an iOS app to a public database would really be a bad idea - all server logic should be implemented on the client, and you would also need to hardcode database user name and password in your app.
A better way is to create a server app exposing a set of REST APIs and being responsible of dealing with the database. This way you can better control at server side what the app client is able to do on the database.
If you have an order entry app, for instance, you can create APIs to:
login
register
create an order
modify an order
add a contact
delete a contact
etc...
Some of the advantages are that:
in case you need to update the logic (but not the API interface), you just need to update the server, whereas in your scenario you'd need to release a new version of the mobile app
you control and limit how client apps access to the data (preventing for instance a user to access another user's orders)
if you want to develop the same app in another platform (android, ...), you reuse the same APIs
To get started, I'd suggest you to read the AFNetworking tutorial on raywenderlch.com, focused on a ios networking library, but talking about JSON, REST, remote APIs etc.
Next you have to choose a server side technology - the most popular nowadays is node.js - to get started you can read other tutorials on the same website:
http://www.raywenderlich.com/61078/write-simple-node-jsmongodb-web-service-ios-app
http://www.raywenderlich.com/61264/write-ios-app-uses-node-jsmongodb-web-service
if you don't want to use node.js and/or mongodb... the same architecture applies, just languages and technologies differ. Just transpose what you learn from there.
If you want to read about other languages to use at server side, just google for it - if you want to use ruby, try with ios rest api server ruby.
Note: I made no mention of swift because your question looks more like an architectural problem than a language specific problem. The tutorials I mentioned here use objective-c, once you've designed an architecture and chosen the language at server side, you can start looking into how to call REST API from swift.

Related

Which backend service to use for iOS client, flask vs node.js vs firebase firestore?

This is not a coding query. Rather an starting point query.
I am new to iOS app development. I have been given a project by my university to make two iOS applications. One application will store few information about dustbin, like the dustbin's serial number, its type and its location in the campus. The location are named as zone A or B or C. These locations will contain their respective geographic information. These information will be sent to another iOS app. The second iOS app have the functionality of generating a map and routing the app user to the dustbin location. The map and routing facility is to be provided by HERE APIs (it is a constraint, and I cant be flexible with this). All this information flow will be facilitated by a server in between. Also, there should be a database storage management system.
Now note that, the server is not generating any active information itself. It is acting as a PASSIVE element. Client_1 is sending the message to Client_2, and this message is going through the server. this message is of course stored in a database.
Now I have few questions, or I should say few points that I dont understand and I am stuck at it.
Should I use Flask or node.js or Firebase firestore is sufficient?
If I do need to use firestore with flask or node.js, where shall I implement the firestore framework, on the server side (flask or node.js) or at the client side (iOS) ?
If I have to use the firestore in client side, do I need to implement it on both the client codes?
Given that I have to use firestore with one of the server, which one shall I use? Flask or node.js?
The above are few queries, which will help me get started on iOS app development. (Note that the iOS coding is being done with Swift 5.1)
Thank you all.
Firestore will work only as your database, where you could keep collections and documents, regarding the dustbins. As mentioned in the official Firestore documentation:
Use our flexible, scalable NoSQL cloud database to store and sync data for client- and server-side development.
So, you can actually develop your applications using it on either client or server sides. It would depend more on what you would prefer. Firestore supports Node.js, so, considering that, using Node.js makes more sense than Flask.
You can get a nice tutorial on how to do that, accessing the below article.
Write to cloud Firestore using node.js server
However, it's possible to use Firestore, as very well explained in this article, directly with Swift.
There isn't a "final" or correct answer for your question. For this reason, I would recommend you to take a look at both of them and make the decision based on your knowledge and preferences.
Let me know if the information helped you!

Connect app to real MYSQL database

I've used React Native for about 2 months now and I've learned a lot already. Now I wanna know how to connect my app to a SQL database. I want to be able to log in, register and chat. I've already built the log in, register and chat screen but I just need one function that can communicate online with a database, I guess. This must be possible... If so, how? A quick answer would be highly appreciated!
Update: This question was asked simply because I didn't recognize some programming terms back then... If you are asking yourself the same thing, search for "RESTful API" and then your desired programming language.
Update
This question was initially asked bescause of my lack of knowledge with backend and general APIs (Look at the title, it's obvious). After one year plus (now), I'm selling my own services and products to other corporations, professionally.
What you're wanting is a web api. Essentially, you will build a web application that you can access over http. You will most likely want to use RESTful web calls. Your web application will then take those REST requests, access your database, operate on your data and return a data response (JSON or XML). Then your iOS app would receive that JSON response and do whatever it needs to with it.
You can build a REST API out of pretty much any server side language, so pick one you like or feel comfortable with and start there.

ios native app talking to an API or direct database connections?

Folks,
Designing an ios application, and would like to confirm my strategy. There is a database (dynamo/mongo/etc) i am building up, which the app needs to make use of. Is it smart to front the database with an API, and have the ios app authenticate against the api.
This way the app makes calls to the api instead of directly to the database?
Would you suggest node.js be a good place to start crafting the web api with?
Thanks!
Yes, access the data via an API. Whether fancy authentication is needed, depends on what is stored in your database, and what your application is designed to do. Here is one resource (among millions) on API design: http://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api
Also, here is a popular networking library for iOS: https://github.com/AFNetworking/AFNetworking
As for what technology to use, that too open ended and you will get 10 answers for every technology available. This should help though: https://softwareengineering.stackexchange.com/q/154519/44948

How to create a server accessible by an iphone app

I a thinking of creating an iPhone/iOS app that would include a feature where one user could create a list of words and then save them to their account on a server. Also (and this is very important), the user could share their list with other users by giving them permission.
So my question is, how can I go about creating such a server? For right now, I have a home computer (running Windows XP that just stores data for my music system) which I can use to host the server. I am also open to the use of other online storage services like Google Drive or Dropbox (I can't remember if Amazon does anything like that). However (and I know this may complicate things a bit), but at least for now, I want/need to stick with free services/options.
Just to recap, the key features that I am looking for are:
create users/accounts (on the server)
eventually I may [try] to incorporate the use of other services to log users in like with their email account, OpenId, etc.
the ability to access (log in to) the server (with credentials) from my app
the ability to send/receive data between the server and my app
the ability to share data between users
I know this is a lot to ask for, but if anyone has any suggestions or can get me going in the right direction, it would be much appreciated.
The basic setup would be as follows:
Backend: Database (MySQL), Web server (Apache), with server side scripting (PHP).
Client: iOS device with developed app.
Communication: use HTTP client/server model, communicating with something like JSON.
This is much the same setup as a web server, but instead of serving html/css/javascript etc the results will be JSON.
As far as implementing specifics such as login in, and sharing data between users, this is purely dependent on your implementation. This is not trivial, and not something that can be easily stated in a single post.
Hope this helps.
You could build your own webservice in PHP, Ruby or Python. If you do so I would recommend building a RESTful webservice (http://en.wikipedia.org/wiki/Representational_state_transfer) and then use RestKit (http://restkit.org/) to handle the data in the iOS app. Especially RestKit's CoreData integration is nice in my opinion.
Another solution would be using a service like Parse (https://parse.com/products/data). The first million or so requests per month are free but after that it could get pricy. I personally have not tried it so I couldn't tell you if it is any good.

Communication between Rails apps

I have built two rails apps that need to communicate and send files between each other. For example one rails app would send a request to view a table in the other apps' database. The other app would then render json of that table and send it back. I would also like one app to send a text file stored in its public directory to the other app's public directory.
I have never done anything like this so I don't even know where to begin. Any help would be appreciated. Thanks!
You requirement is common for almost all the web apps irrespective of rails, Communicating with each other is required by most modern web apps. But there is a small understanding that you need to get hold on,
Web sites should not directly access each others internal data (such as tables), (even if they are build by the same language (in this case Rails) by the same developer),
That is where the web-services comes in to play, So you should expose your data through web services so that not only rails application can consume that, but also any app that knows how to consume a web service will get benefit.
Coming back to your question with Rails, rails supports REST web services out of the box, So do some googling about web services, REST web services with rails
HTH
As a starting point, look at ActiveResource.
Railscast
docs
Message queuing systems such as RabbitMQ may be used to communicate things internally between different apps such as a "mailer" app and a main "hub" application.
Alternatively, you can use a shared connection to something like redis stick things onto a "queue" in one app and read them for processing from the other.
In recent Rails versions, it is rather easy to develop API only applications. In the Rails core master, there was even a special application type for these apps briefly (until it got yanked again). But it is still available as a plugin and probably one day becomes actually part of Rails core again. See http://blog.wyeworks.com/2012/4/20/rails-for-api-applications-rails-api-released for more information.
To actually develop and maintain the API of the backend service and make sure both backend and frontend have the same understanding of the resources, you can use ROAR which is great way to build great APIs.
Generally, you should fully define your backend application with an API. Trying to be clever and to skip some of the design steps will only bring you headaches in the long run...
Check out Morpheus. It lets you create RESTful services and use familiar ActiveRecord syntax in the client.

Resources