There are 2 iPhone applications. One application running in the foreground and the other running in the background. Is there any way to get the background application to send data over USB without coming into foreground? Ideally we want to keep the foreground app in the foreground, while the background app process some data. Once the data is processed it will inform the foreground app that the data has been processed.
-
I'm putting this in comments since I'm really clueless, but: why not run the background process as a background thread within your main application? I'm pretty sure iPhone apps don't run in the background, which means this is probably your only choice anyway. – MusiGenesis Nov 23 '10 at 22:35
-
iPhone apps can run in the background, but it's completely unnecessary. Background threads are also unnecessary. Just use asynchronous I/O! – tc. Nov 24 '10 at 00:24
3 Answers
No it cannot. It cannot even do this without the use of private frameworks, unless you're in the Made for iPhone program. If you are, then your organization will know, based on the documentation made available to you, what you can and cannot access, when and how.
Should you be in the Made for iPhone program, and are unclear as to what you have access to and when, contact the person in your organization who is the technical contact with Apple for this program, they will be able to give you the details.

- 20,094
- 5
- 45
- 69
If the task is started while the app is in the foreground and you call the appropriate beginBackgroundTask/endBackgroundTask methods, you should be able to have it continue running after the app is backgrounded.
Note that access to USB is restricted (see jer's answer) and that there's no officially sanctioned way to communicate between different apps on the same device. Also, you can only buy/download one app at a time in the App Store and I can't see Apple approving an app that required you to download a second app for it to work. So you may have bigger problems to solve first.

- 16,130
- 5
- 49
- 43
-
Thanks very much for the quick response. If access to USB is restricted, is there a Bluetooth API available to transfer data? – Lexy Nov 23 '10 at 23:50
-
Just to clarify, the device the data will be transferred to, is a non-iOS device. – Lexy Nov 24 '10 at 00:03
It would help significantly if you told us what you actually wanted to achieve. For example, "I want MyApp on the user's phone to communicate with MyApp on the user's computer".
The absolute easiest way is to send data between the phone and a computer is to require that they're both on the same Wi-Fi network. Several iPhone apps incorporate a web server (this was the easiest way of "file sharing" before OS 3.2), and many more iPhone apps connect to a computer running server software.
Your other options, more or less:
- Reverse-engineer the Bluetooth side of GameKit and reimplement it on the computer-side. I'm not aware of anyone who's done this. Loosely, I think it's IP over Bluetooth PAN plus some sort of Bluetooth service discovery.
- Audio input/output, e.g. the headphone jack or certain pins on the dock connector. I'm not entirely sure how the mic side works (the resistance was a bit high for a carbon mic when I checked), but you might get lucky and find a way to turn it into "line in" or find "line in" pins on the dock connector.
- A webcam pointing at the iDevice screen (and the iDevice camera pointing at the computer screen). Ewwwww.
- Join the MFi program.

- 33,468
- 5
- 78
- 96