Search code examples
iphonemacositunescommand-line-interface

How do you get the charge status of a connected iPhone from the Mac?


In iTunes, you can see the charge status of the iPhone currently connected:

Screenshot of iTunes showing an iPhone in the list of devices with the charge status indicated.

This updates as the phone charges, and even shows when the phone is done charging.

Is there a way I can discover the charge status programmatically from the Mac? Any programming language or API is fine.


Solution

  • As far as I know, the only official way to communicate with the iPhone over USB/Bluetooth is by signing up to the "Made for iPhone" program:

    http://developer.apple.com/programs/mfi/

    Unfortunately the documentation seems to be closed to registered members so I can't find out if the API for this is public or private. You could contact Apple to check before applying.

    UPDATE : As mentioned, this might not work for Mac/PC <-> iPhone communication over USB. There are several apps that do things with the phone over USB (although usually for reading/writing files). I'd start by looking at the source code of those:

    http://code.google.com/p/iphonedisk

    This should put you at least in a position where you have a connection to the device and are able to send/receive commands. Everyone who's ever done this sort of thing has had to spend time reverse engineering the thing :) The jailbreak community might be able to provide some insight too, although having to actually jailbreak the device is probably unacceptable.