开发者

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:

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

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.


I would recommend setting up a bonjour service in an App on the iOS device to communicate with the computer. The app will then communicate the changes in the batter status using the batteryMonitoringEnabled property of UIDevice. Take a look at the samples code here.

BatteryStatus Sample Code

And here is the class reference

UIDevice Class Reference

And finally Bonjour programming

Bonjour programming guide


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜