setting up server for an iphone app - iphone

super basic question - I am building an iphone app but will need to set up my computer as a server so my app can send data to my computer. what are the first steps that i need to take?
Thanks!

If you are writing an iPhone app you are probably on a Macbook so you can easily enable Apache in system preferences, click sharing, enable web sharing it will then show you your computers IP address that you can hit over a web browser.
That will set you up with a web server on your machine. Since your emulator and web server will be on the same wifi network and even if you deploy to the device you can have it on your wifi network you should be able to post data to your Mac's web server.
If you are passing data to it you'll need to read about 'web services', probably REST web services. I would then suggest reading about PHP and/or Ruby or Python as your programming language to interpret what you are posting to the web service.
Hope that helps you on your way.
If you are not on a Mac you can't develop an iPhone app anyways ;) so the above strategy should work for you.

3G will only work for you if your server is available outside of the network. Tons of info online on how to set that up but essentially what you would do is configure your router to forward incoming traffic from (for example) port 8080 to the ip address of your server. Assuming you are on a router.
As a side note, if down the line you use Ruby you could check out http://www.heroku.com/how if you want to host your server there

Related

Scrape HTTPS REST API from an Android app installed in computer

We are building an Android App and we are worried about the REST API being scraped.
Would it be possible to detect the REST endpoints used for the app if somebody manages to install the app in a computer and uses a software like Wireshark to sniff the connection?
The connection is HTTPS
If possible, what is the way of preventing people from using these REST APIs on their own?
We are building an Android App ... if somebody manages to install the app in a computer
I.e., you're worried about either 1) a computer running Android or whatever Google's "Android+Chrome merge" thing is or 2) a computer running some software under which Android apps can run?
and uses a software like Wireshark to sniff the connection? ... The connection is HTTPS
Sniffing an SSL/TLS connection gives you a bunch of encrypted data unless you give Wireshark enough data to decrypt it, and it's a situation where it can decrypt it.
However, a debugging proxy such as Fiddler or Charles might be able to catch the traffic and decrypt it in situations where Wireshark couldn't.

iphone app private test network

I am developing an iPhone app that relies on a custom web service I created using Ruby on Rails. I want to setup a test server on my Mac without having to change the URLs that my app is pointing to - served by the RoR service. This way I can test new features or fixed bugs more easily using the test RoR server.
I have enabled internet sharing on my Mac so I can connect with my iphone to a private wifi network. I installed dnsmasq and edited my /etc/hosts file to resolve my web service URLs to the local gateway ip. However when I use my iphone app the URLs are resolved to the production server instead of my test server (my Mac).
How do I setup dnsmasq to point to the local ip.
Thanks!
Have you set the DNS server address on the iPhone to the IP address of your Mac?
After playing with it some more I was able to get it to work. I needed to edit /opt/local/etc/dnsmasq.conf and change the 'address' tag. I also had to change my Mac ethernet settings, under advance->dns I had to add 127.0.0.1 as the first dns server. This will automatically change resolv.conf which is not meant to be edited manually on a Mac.
After reading up a bit on the Dnsmasq solution, I found a nice step-by-step guide for Mac: http://davesouth.org/stories/how-to-set-up-dnsmasq-on-snow-leopard-for-local-wildcard-domains
(although personally I use Fiddler in a Windows VM for all of this sort of thing - ask if you'd like some details on that..)

How to sniff iphone network data

I have recently been having problems with my app and I need to view the data being sent to and from my iPhone. I have read about Paros and downloaded it, but I don't know what information I need to put into paros and my iPhone to make it work. I am running a normal windows 7 installation with no current proxy server and my ISP is telus with the fiber optics package. So what do I need to install and where do I find all of the information needed to read the data being sent over the network by my iPhone using paros?
I do this a lot. I do it with a MacBook, but I'm sure you can use a similar technique to do it from windows:
Connect your PC to a hard-wired ethernet to the outside world.
Set your PC up for internet sharing. (This is the big thing that will work differently between the Mac and PC). Set up to share your Hard-wired Connection with people from your WiFi Connection. Your computer will then become a wireless access point.
Connect your iPhone to use your PC as it's WiFi network
Download and run Wireshark (Open Source - Publicly available) on your PC. Wireshark will sniff and log the network traffic.
You can then obviously set up whatever rules your would like to limit your network trace to only your iPhone.
Like I said - I do this all the time with a MacBook and it's easy and powerful!

iPhone HTTP Server

Can someone give me simple code to help with creating an HTTP server for the iPhone. Something simple with much documentation would be appreciated. Anything you have please share.
There are sample codes from Apple and open source community such as cocoahttpserver TouchHTTPD.
Here's a summary blog
Another open-source HTTP server for iPhone is the lightweight GCDWebServer which is built on top of Grand Central Dispatch. It's only a few source code files and offers a simple and extensible API.
If you're unfamiliar with network programming your best bet is to first read Beej's Guide to Network Programming and then read the HTTP 1.1 spec before you look at source code (as you should have an understanding of the protocol before you start looking at implementations).
A simple Google search turned up cocoahttpserver and iSpit. Otherwise, you could download Apache and look at its source code, but that's not exactly a simple implementation.
It is possible to run a simple file server on iPhone/iOS.
I was able to use this method successfully. Here are the steps to create a simple file server which works on http protocol.
1. Install TestFlight app for iOS
2. Install iSH app from the Apple store or side load it from their website, as this app might not be available in the store depending on your country. I tried it from india in May 2020, and the app was not available in the store. So i did side load it from their website.
3. With iSH app, one has access to linux kernel of the iPhone. I did use a simple http server module from python and executed it on the linux shell.
4. Command to run the python based server on iPhone :
Python -m http.server 8080
5. Access the file server using the local ip that’s assigned to the iPhone in the network you are connected to. That means, if iPhone is connected to a WiFi SSID, depending on whether the router is configured to use static IP address assignment based on MAC address or using DHCP protocol, your iPhone will have an internal IP assigned by the router.
6. Command to access the file server :
http://192.168.1.3:8080 - modify the address depending on IP address of the iPhone and the port that server running on iPhone is configured to use. Paste this in a browser - one should be able to see the files listed in the directory where the server is running in.
Hope this was clear enough, for running a simple http based file server on iPhone using http.server module in python, over linux shell of the underlying kernel, using iSH.

Options for iPhone app which requires VPN?

I was thinking about creating an iPhone app "front end" for one of our internal systems.
I suspect this will need to run via a Cisco VPN (connecting with a key code).
What are the options to do this on the iPhone?
Do you need to manually connect to a VPN somehow using the iPhone and then start the iPhone app?
Or can the app prompt users to enter their key code and then start the VPN session?
No, (as of iPhone SDK 3.1.2) there's no API provided by the SDK to manipulate VPN connections. The user will have to manually connect to the network.
While there may not be an API available to manipulate the VPN itself, as of iOS 3.0 enterprises can at least enforce hosts within particular domains be accessed via a VPN, and "VPN On Demand" can be used to turn on the VPN when a given resource is being accessed. Without the enterprise deployment tools though, I suspect you're out of luck.
It doesn't sound like the application will be able to have any insight in to any of this happening, though.
Ref: http://support.apple.com/kb/HT1424
Try iSimplyConnect - it support Dial-On-Demand.