This question already has answers here:
How to connect amazon RDS in iOS
(3 answers)
Closed 3 years ago.
I am building an app for the first time and it requires a back-end connection with the database. I've established a working EC2 and RDS instance in AWS (also trying out for the first time). I don't know how exactly to establish a connection in Xcode with a .php file, there's a couple missing holes in my knowledge that I hope someone can clear up. Every online resource I've looked up doesn't use the exact stack that I'm using so I get confused as to where to go from here.
How would I go about connecting to my Amazon RDS (mySQL) credentials inside my XCode project? Also would I save a separate .php file with the server connection and insert the URL of the file from my local directory? I know I have an endpoint URL provided by RDS, I'm just confused as to how to go about connecting all of this in order to start the POST/GET requests. There isn't a clear tutorial on this, so hope to get some answers here.
The reason why you can not find tutorial on this subject is because it is not considered a good architecture practice to connect backend databases directly from mobile applications. Not only you have the problem of providing the mobile application with the database credentials, in a secure way, but also it would oblige you to implement the access and authorization logic in your mobile app and will create a hard dependency between your mobile and the database endpoint. What if it crashes ? What if you need more CPU/Storage on the server side to accommodate client requests etc ..
The correct architecture is to expose the data required by your mobile app through a API. AWS has several options to let you create an API (API Gateway and AppSync). In both cases, the amplify command line will generate the XCode Swift code for you for easy integration with your app.
See https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-generate-sdk-ios-swift.html
See an iOS code sample here https://github.com/sebsto/reinvent2018-mob320 (it doe snot have RDS integration in the backend, I will leave this as an exercise for you)
Searching the web, you will find other persons having post similar questions and having received similar answers :
https://forums.aws.amazon.com/thread.jspa?threadID=136902
How to connect amazon RDS in iOS
Related
I'm an iOS developer with little backend knowledge. I've been using Firebase to create the backends for my apps for over a year now and it's worked great. My latest client wants an app with a relatively simple backend, which I would have no problem creating with Firebase, but due to their privacy policy they require that all collected data be stored on their in-house servers. Interestingly they have a server room with IT techs, but no developers.
My question is: is there a way to host Firebase on your own server instead of using one of Google's? I've searched around for the answer and unfortunately the consensus seems to be no, however, I have seen a few posts from years ago saying that this service is coming in the future. Does anyone know if its here yet?
No, this service is not here yet. One alternative you might consider is Parse Server - an open service, host yourself, replacement for Parse.
https://github.com/parse-community/parse-server
https://www.raywenderlich.com/146736/parse-server-tutorial-ios
I am running a site right now with a quite big MySQL database.
Now, I want to create an app. I will need to use obviously a database de to the fact my data are already there.
Thus,
1) Should I keep using the MySQL server and my iOS app will connect to this MySQL serve for getting data?
2) is there any problem if I use the MySQL server ? Security issues maybe?
3) if I have to change the MySQL server, what database infrastructure I need to build and work with?
I am totally newbie on iOS apps. And now I planning to face any issues my iOS app will have.
Since you are running a site with MySQL I think a lot of your questions have been answered. You already have seen how your MySQL database performs in a production environment. Unless you believe that your iOS user base is going to be much larger or perform very different functions you currently have valid performance benchmarks.
In terms of how it relates to the iOS app, you can build an API, or make calls to https pages on your website that will return the information required for your app. For information on how to do this, check out this AFNetworking tutorial.
In the end, there might be some reasons that your current database isn't the right choice for your app. But since the app won't be interacting directly with the database, you can change it out later and you will only have to integrate the database with the interface and not change the iOS app at all.
I am trying to develop my iOS application that requires a backend for simple CRUD functionality and also a server that helps me link up players and handle real-time multiplayer game logic.
I am using AWS DynamoDB to store my user's data and believe I would need to set up an EC2 instance to help me with my multiplayer game feature. I am completely new in this area and I hope to get some help in these few elementary questions:
Does the different instance (linux or windows) matter?
What language is it required to set up the server-side code? Or is server-side coding necessary?
If the language in the server-side is different from that of xcode's how does it handle the calls? (Please bear with me if this is really fundamental)
Is there any guide for setting up AWS EC2, and must those guide be specific to iOS for my app to work?
Thank you so much for all your help!
Probably
Whatever you want to use, and yes it is necessary
You have different options here, you can do everything from sockets to REST or SOAP.
An EC2 instance is, as far as your concerned, just a server running a back end service for your application. You need to figure how you want the application to work first. It doesn't matter if you decide to host it on ec2 or another service.
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.
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.