Getting the specific IP location for iPhone application - iphone

I have gone through following link
http://zachwaugh.com/2009/03/programmatically-retrieving-ip-address-of-iphone/
and I have also tried this one (but this isn't recognized by Apple).
http://appsamuck.com/day4.html
I just want that when user tap on "wifi" button.
Reports stored in documents directory can be accessed by other pc using wifi using the IP that I display on my iPhone application. How is it possible?

In my apps, I use CocoaHTTPServer to get local info into and off of the phone. You run the server and out-of-the-box, it indexes all the files in the documents directory.
To do what you want, you will need to edit the code to return some other kind of data format (xml probably is the easiest) the call this from inside your app to get that data. CocoaHTTPServer easily take POST right out of the box too, so you can post an xml response as well.
After thinking about it, CocoaHTTPServer is best run on the computer side behind the scenes. the iphone can then send info to the computer where handling the code should be easier and you have more options.

I can't point to any specific examples but the way to do this would be the ZeroConf protocol - both the iPhone and PC would have to be on the same network to have this work.

Related

Install .mobileconfig Programmatically

I am writing an app in order to automate the process of connecting an Apple mobile device to a wifi network and downloading configuration profiles to the device. Since it is being automated (by something such as Native Driver), all of the functions need to be controlled by the app itself, not sent to another app such as Settings or Safari.
I am already using Apple80211 private framework to connect to a wifi network as well as UIWebView in place of a browser in order to navigate to a specific webpage. Once I navigate to this webpage, my server will send the mobile device a .mobileconfig file in order to install a configuration profile. I haven't been able to find a clear answer on how to handle this .mobileconfig file once it is sent by the server. I have read in a few different places that UIWebView cannot handle the .mobileconfig file once it is sent. What would be the best way to handle this file when it is sent?
Also, once it is sent, and granted that something can handle the file, is there a way to install the configuration profile programmatically without the need for user input? i.e. are there any public or private frameworks that I can implement in order to install the configuration profile "behind the scenes?"
This app is only ever going to be used for testing purposes, and will only ever live on a handful of devices. Thanks in advance, any help will be much appreciated.
I tried a similar thing to do.
Unfortunately I didn't get it running with the UIWebView, but with switching to the Safari it worked:
Switch to safari, let the user install the config and send him back to your app. Just register to a custom URL Scheme like "yourapp://" and add a link to this URL in the HTML.

Showing dynamic web-content from iOS local server (i.e. using browser as remote screen)

I want to show some really simple graphics in a http-page in the local network using an iOS App as local server.
Now I heard showing some http-page over the local network is quite easy, using for example CocoaHTTPServer.
Would it also be possible to adjust the content of the page dynamically, from the iPhone side?
Meaning
user types in URL at the desktop-pc-browser of his choice
user goes to his sofa, flicking through text/images with his iPhone, looking at the remote screen
(no need to go to the browser to refresh page?)
Would this be feasible?
Of course I could also try to set up some Bluetooth-Connection, connecting between iOS/MacOS Apps, but I figured the browser version would be much more flexible :)
Stable connection? No need to support each and every browser? Then open up a websocket connection between your app and your browser. You’d then advise your browser to reload or show another picture through the websocket.
If you need to support more browsers, you might need comet / long-polling support. I’m not sure, though, whether CocoaHTTPServer supports it.
If none of these work, you could have your webapp do an Ajax request every now and then, in order to check whether something has changed.

How can I send my app data from one iPhone to another

I built an app which I can add images and texts, what I would like to do is to pack a data from this app (which I can do that by serializing an object to a file) and send it non-synchronically to another app in another IPhone and open it there (without using the mail nor the internet).
for example if I had MMS on IPhone I could do that by sending the file as MMS and set my app to open files with specific post-fix I choose.
Please help, Thanks.
What do you mean by "without using the internet"? You could use NSNetServices to establish connections between devices, and send whatever you want between them. This relies on the TCP/IP protocol though, but does not use HTTP. So if you mean "without going via HTTP", this should be an alternative:
http://developer.apple.com/library/ios/#documentation/Networking/Conceptual/NSNetServiceProgGuide/Articles/ResolvingServices.html#//apple_ref/doc/uid/20001078-SW1
you use an url scheme for small data, or the new UIDocumentInteractionController

Where can I find an iPhone address book with sample data?

I'm developing an application that get access to the iPhone address book.
The simulator contains only a few sample entries.
I'd like to find a sample address book with thousands of entries with various
character set (English, Chinese, Arabic, etc) to fully test my app.
Filling the address book myself will take for ever.
Basically I need a AddressBook.sqlitedb file with as much data as possible
A csv would probably do just fine if there is a way to transfer it into a sqlitedb file
Good question, I'll have to give this a go myself later, but just from combining a few things I found around the web the following might work for you:
Install Sun OpenDS and fill it with test data using the checkbox provided
Connect your Mac's address book app to this directory server on localhost and sync (will fill your local address book with the same sample data)
as described here: http://blogs.oracle.com/treydrake/entry/mac_address_book_and_opends
Sync to a real iPod/iPhone
Extract the resulting files from your iPhone/iPod's
/User/Library/AddressBook/
and copy into:
/Users/[your user name]/Library/Application Support/iPhone Simulator/[iOS version]/Library/AddressBook/
if your device is jailbroken 'Phone Disk' from macroplant.com is a convenient way to do this (but there are of course many others including SCP etc)
(if your device isn't jailbroken, you can extract the database from a backup using the shell script here: http://0xced.blogspot.com/2009/01/using-your-own-address-book-in-iphone.html just note you'll need to change the path it copies it to to the one above, or your home folder or something and copy manually, as the simulator path in that post is for the previous version of the SDK)
As a minor aside but related to address book testing, I'd highly recommend also adding an Exchange account on a real device (as you can't do that in the simulator) and testing with that - it threw up some bugs in our app (crash on attempting to access the address book).

Debugging iPhone App from Command Line

I can do it from XCode, but I want to be able to launch an iPhone App (on the device) from the command line. Is it possible?
Why? Because I want to capture some of the output for semi-automated testing. I'm guessing I need to use a debug build for NSLog output, but I'd also be interested to know about other methods for getting NSLog / stdio data back to the host Mac.
There is a project on github called titanium_mobile (part of Titanium Developer).
I use a utility from that project called iphonesim. It launches an iPhone app from the command line (though I am not sure how, I think there is a way to do that with SpringBoard.app). If you take a step up one level in the Titanium Mobile code and look at builder.py you can see how they launch an app in the simulator and capture the output.
Ultimately I solved my specific need a different way. I needed to get data from the iPhone's accelerometers into a prototype app in Adobe AIR(Flash).
I used this app on the iPhone which drops UDP packets with X,Y,Z forces in them.
http://code.google.com/p/accelerometer-simulator/wiki/Home
Found that from this blog post which might be of interest to people trying to do other similar things.
http://ifiddling.blogspot.com/2009/01/dummy2.html
I used a Python script to present a server to Flash, grab UDP accelerometer packets, munge them into AMF and send them to Flash. Flash uses a socket to connect to this server and receive the accelerometer data.
A few parts, but it works nicely.
You can do this on the device if it is jailbroken. You can put a debug build and symbols on your device and run gdb on it. It is totally unsupported but I hear it works. Not sure if there is a good tutorial. Google?
One method would be to use the AsyncSocket class, and pass whatever data you want to log from the iPhone to a basic host app on the Mac, which NSLogs whatever it receives. If you follow the EchoServer application, you should be able to integrate it in just a few minutes