2

I've been using iBetterCharge for some time and I quite like it. Except the fact that sometimes it's annoying with its loud warning sound.

Anyway, I'm wondering how do apps like iBetterCharge and coconutBattery work? I mean how do they read iPhone batter level over wireless networks?

My personal research did not reveal much regarding how to read the battery level of a device programatically. However, according to the iBetterCharge FAQ they do not talk with iPhone at all. They say the app communicates with the device using the data which iTunes itself gathers.

But how?

itopaloglu83
  • 216
  • 1
  • 5

1 Answers1

3

It uses protocols which iTunes itself uses to sync with iOS devices. FAQ says everything you need to know. Check out libimobiledevice This library implements those protocols and can be used to retrieve battery info. I know it works over USB but don't know in which state is networking implementation (it says WIP).

You can try example here. You need to pass com.apple.mobile.battery as domain to retrieve battery info.

creker
  • 9,400
  • 1
  • 30
  • 47
  • Thank you for the reply. Yeah, I read the FAQs page. What confused my mind is that they say they're "using the data which iTunes itself gathers". [FAQs Page for iBetterCharge](http://softorino.com/ibettercharge/faq). iTunes must be syncing with iPhone frequently over WiFi to show the batter information on iTunes. What I can't figure out is how to get that data from iTunes. I couldn't find anything regarding this. Not on libimobiledevice either. – itopaloglu83 Aug 04 '15 at 17:46
  • I don't think they meant that. What they mean is that they're using the same data that iTunes uses to display battery info. They both use the same protocols which iOS devices expose by default to get that data. They don't do anything special. libimobiledevice is a custom implementation of that protocols. I looked at the application - they're linking against iTunesMobileDevice.dll on PC so it means they're communicating with iOS devices directly without iTunes help – creker Aug 04 '15 at 19:16
  • that explains a lot. I don't how to check for those kind of relationships for apps. The only thing is that their FAQs page reveals that iBetterCharge cannot get the battery level data is iPhone is not setup to sync with iTunes over wifi. They must be using iTunes code to bypass some authorization process of some sort. I wish I knew ways to come up with these kind of coding procedures. Anyway, thanks for enlightening me. – itopaloglu83 Aug 06 '15 at 17:40