How to retrieve battery and system info on the iPhone

Discussion in 'Mac Programming' started by futuremacdev, May 1, 2008.

  1. futuremacdev macrumors newbie

    Joined:
    May 1, 2008
    #1
    Hi guys,
    I'm just starting out with the iPhone development, so maybe I'm asking something simple. I need to programmatically retrieve some system info, such as the battery charge percentage, whether the battery is currently charging, the CPU frequency and other system info. Do you know how to do it?

    I've searched the docs, but there's not a single reference to something with "battery" in the name. There are a few C functions for the Mac OSX, and even a complete BatteryInfo sample project, but nothing for the iPhone. Is that possible?

    How was the BatteryInfo and HWInfo apps written for the unlocked iPhones, if there is no documented functions for this?

    Any help is highly appreciated!
     
  2. futuremacdev thread starter macrumors newbie

    Joined:
    May 1, 2008
    #2
    nobody?? wow, and I tought it was an easy question...:)
     
  3. himansk macrumors regular

    Joined:
    Oct 16, 2006
    #3
    The unlocked phones use a completely different API, I dont think the official API has exposed the hardware information to the developers otherwise I would expect somebody to have already answered your question.
     
  4. futuremacdev thread starter macrumors newbie

    Joined:
    May 1, 2008
    #4
    yeah, I guess you're right...but let's admit it, it sucks! I mean, knowing the battery status is a pretty important need for many mobile apps, how could they avoid adding an API for it???

    Say for example I'm using the Localization API. If the battery is full, I can update the position every 10 seconds...if it's low, I may decide to update the position every 60 seconds. But if I don't have the battery info...:(

    The SDK as it is doesn't impress me much..let's just hope they'll fill the blanks..
     
  5. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #5
    If the battery is full, update the position every 60 seconds - so that the battery doesn't go low that quickly. Maybe Apple missed making the functionality available, maybe it's hidden somewhere, but maybe they just don't want you to rely on that knowledge so that you _always_ try to safe energy.
     
  6. futuremacdev thread starter macrumors newbie

    Joined:
    May 1, 2008
    #6
    That's just an example of many.
    Anyway, Apple should care less about what I do...if my app performs bad or drains the battery, I won't have any success and people will just uninstall it...but that's my business, not Apple's...
    They should just give devs more freedom if they want the iPhone be a read application platform :rolleyes:
     
  7. Sayer macrumors 6502a

    Sayer

    Joined:
    Jan 4, 2002
    Location:
    Austin, TX
    #7
    Polling is a bad idea no matter what platform you do it on. Unless you are trying to turn the iPhone into a GPS navigator thing like TomTom you don't need to constantly poll.

    Apple's location app updates when the user tells it to; radios are battery draining hogs so their use is supposed to be only when absolutely needed.
     
  8. himansk macrumors regular

    Joined:
    Oct 16, 2006
    #8
    If a phone suddenly starts draining the battery very quickly, most often the user will blame apple for it. so they are concerned of this and will try to get the developers to write better code and better apps, coz it all reflects on apple in the end.
     
  9. futuremacdev thread starter macrumors newbie

    Joined:
    May 1, 2008
    #9
    Well, Win Mobile and Symbian does not have such limitations, and AFAIK users don't blame MS or Nokia for specific crap utilities, they blame the utilities' makers. Anyway, I don't see a single reason why Apple shouldn't give me battery and hardware info...it's my business to use such info the correct way. If they keep all these limits, no wonders that many devs will just produce software for the unofficial unlocked OS...
     

Share This Page