5

I want to know if an iPhone is connected to USB programmatically.

So far by googling i found http://developer.apple.com/programs/mfi/.

Do I really need this api to find out whether an iPhone is connected to USB device?

I just want to make an iPhone app that prints out in console whether the iPhone is connected with USB or not.

Thanks much.

Steve Ham
  • 3,067
  • 1
  • 29
  • 36

1 Answers1

2

You might be able to use the solution from this question.

The solution detects if the device's battery is currently being charged which, if connected to USB, most likely will be unless it is a 3rd party accessory in which case there's a different SDK for those I believe.

In any case, if the solution isn't helpful it might point you in the right direction.

UPDATE: Did some more digging and it appears that this may not be possible other than the battery charging solution mentioned previously.

So to answer your question "Do I really need this api to find out whether an iPhone is connected to USB device?":

Yes, it appears that way.

Community
  • 1
  • 1
Beltalowda
  • 4,558
  • 2
  • 25
  • 33
  • Thanks much was able to find out the USB status with the battery status http://www.evernote.com/shard/s13/sh/0f274a3e-011c-4e4c-8267-dec968a0fe83/5eab7e9db8345d9f476aa41d6a06dae6 – Steve Ham Sep 21 '11 at 03:08
  • @SeungUnHam,this fails in case of charging of iphone using iphone charger. – virata Jan 21 '13 at 07:49
  • Did you find any solution – Jas_meet Oct 25 '17 at 11:07
  • Well technically the USB would be “connected” during the charge. If the condition is defined as “the port has a cable plugged into it”, then that should always be discernible using the battery charging status. You can also use this status to do other cool things, like throttle FPS on your game when the battery is not charging to save power, then bump it up to max when connected to power. – Beltalowda Nov 11 '17 at 09:50