I'm new to network programming. This is probably a stupid question, would it be okay for my server to be in C++ for my iOS application?
iOS does not care what your server is programmed with. You can use whatever you feel comfortable with. Remember, you aren't going to be sending executable code to the server - you are just going to be sending requests and the server will send a response.
Yes, your server can be written in any way you want, provided you define the correct protocol (method of communication) between your iPhone app (client) and the server.
XML, JSON, HTTP POST or GET's, whatever. It should all work, provided you code both sides correctly.
Related
I just added SSL to my backend framework (Django REST API) and I want my iOS application to talk to it. Do I have to do anything differently on the iOS side of my project? How do I tell Alamofire to encrypt the data its sending? Or Does it happen automatically?
The only difference is using https instead of http. I have the same setup at work, and originally thought I was going to have to delve into certificates. I started heading in that direction and then realized all my requests worked as soon as I stuck the "s" on the end.
I will say, while using NSStream, you do have to setup the stream to handle the certificate. I am doing this in another application, but that is below the URLRequest class. I am unsure of how low level Alomofire actually delves, but it will definitely handle everything you desire without doing anything differently.
Just update URLs inside your app to use "https" and you are done.
I am a beginner to ios development.
Can anyone tell me how to send data to server in xcode?
I have a requirement where I need to send device information to a server.
You need to first work out what kind of API the server you're talking to has exposed
Most modern web applications expose a Rest API (although I can only speculate as to what the server you mention is exposing). If Rest, then a good starting point should you not wish to write your own network layer is to use Restkit: https://github.com/RestKit/RestKit
If not Rest, then you need information on what the backend API is, and then go from there...
In it's most basic format you'll need to look at using NSURLRequest and NSURLConnection
NSURLRequest : Post data and read the posted page
http://codewithchris.com/tutorial-how-to-use-ios-nsurlconnection-by-example/
I am developing a web application with Dart using redstone and polymer
Because Dart allows for server and client side development, I wonder what a good pattern for a web application is (specifically to Dart)
Option 1:
Have a server, say, /bin/server.dart
1.1. get a request there and respond with json
#app.Route("/user/:id", methods: const [app.GET])
getUser(int id) { ... }
have a client, i.e. web/user.html and web/user.dart
2.1 in user.dart make a request to server
2.2 receive json and form a proper user.html
Option 2:
Have a server /bin/server
1.1 get a request there and respond with an html page, similar to
#app.Route("/")
helloWorld() => "Hello, World!";
If in the first case I more or less know (and understand) how to make things work, while i find it really frustrating that I do not take advantage of Dart's server-client code-sharing: I need to encode to and decode back json to get the same data. Is there a way to avoid it?
The second option is much less clear for me: how would I serve a web page in this way? How would I make Polymer do its work?
Answers on the questions in the text and a general explanation of a darty way to develop web apps are very much appreciated.
You can see a Redstone + Polymer application example here: https://github.com/luizmineo/io_2014_contacts_demo
Basically, it works as Option 1: The client and server communicates through a service API, and the data is encoded as JSON. Although, Redstone uses the shelf_static package to serve the client code to the browser as well.
If you prefer, it's also possible to use a server side template engine, such as mustache, to build html pages in the server, although, I think it would be really difficult to integrate that with Polymer.
And finally, you always have to encode the data someway when transferring data between client and server, but this doesn't means they can't share code. They can use the same domain classes, for example. Check out the sample application linked above for more details.
I don't think the option 2 is possible. Polymer depends on dart:html which is not allowed on server side.
I'm currently developing a server that can get data over the internet from specific device i have and log it into a database. Unfortunately I dont have control on the way this device communicate.
Currently I set an IP adress and a port number and the device will open a socket and send a string. I dont really want to develop a server from scratch and i would much prefer to base on a web server. but the data is a plain string and not a full http request.
Is there a way around it using Ruby on rails ? Is it possible to do with other web-server-based technology ?
Thanks a lot
You can use just a regular old ruby socket to receive the string.
Sounds like an application that node.js would be useful for, if you want a pre-made node+rails app which would do what you want check out compound at GitHub mentioned in this article
I'm just starting to learn about iOS development, and I figure the best way to get started is to build a simple (but non-trivial) app. My idea is this: have a web interface where a user can create a survey, and then access those surveys through the app and send responses back to the server. The web design part probably won't be terribly difficult -- I've done similar things with Django before. The part that will require learning/effort is the iPhone app.
I've got enough Objective-C that the data structures (model) won't be hard to code, and the UI (view, controller) part shouldn't be bad either. I predict that the interface between web and phone will be difficult, though. In particular, how will I be able to access the database on the server from the phone? I'd like to have a single DB that both web and phone apps use.
What I'd really like to have is a general, broad-strokes description of what I'll need to do to get this all up and running. Am I right in believing that the networking will be the hardest part? Are there any other possible snags? Any advice, or pointers to good resources on the subject, would be greatly appreciated.
Networking will probably not be the hardest part here, you're just guessing because that aspect is unfamiliar to you. For example, you can use NSURLConnection to take care of pretty much all the details of server connection. You can use NSJSONSerialization to convert your data to and from a format that is suitable for sending over the wire.
Basically what you might do is:
Mobile app sends a HTTP GET request to the server for survey info.
Server responds with a JSON description of the survey.
User fills out survey.
When done, the app sends the responses back in JSON format as a HTTP POST to the server.
Server stores the results in the database.
One of the key points here is that the app on the phone does not try to access the database directly. All requests go through your Django web app.