Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8191329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:53:40+00:00 2026-06-07T03:53:40+00:00

I am making a GPS app and the accuracy changes based on if power

  • 0

I am making a GPS app and the accuracy changes based on if power is available (ie vehicle charger)

Is there a way to run something in the background that constantly checks to see if a device is receiving power?

I know how to check if power is connected. But the issue is IF the user is at home and connected. He unplugs the device to go out on a run. Then decides to hang out. My app checks the battery state on launch. How can I check it again and again. I don’t want to drain his battery because he was using my app!

We plan on only supporting iOS 5 and higher (no need for backward compatibility with iOS 4 and 3)

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T03:53:42+00:00Added an answer on June 7, 2026 at 3:53 am

    Have a look at the UIDevice class reference.

    There is a property called batteryState that returns a UIDeviceBatteryState. So, to see if the device is charging or is plugged in and full.

    UIDeviceBatteryState currentState = [[UIDevice currentDevice] batteryState];
    if (currentState == UIDeviceBatteryStateCharging || currentState == UIDeviceBatteryStateFull) {
        // The battery is either charging, or connected to a charger and is fully charged
    }
    

    Edited to add

    If you want to continuously monitor the state, take a look at the batteryMonitoringEnabled property and then handle the UIDeviceBatteryStateDidChangeNotification to update whatever you want to.

    iOS is event driven. Checking the state of something within a while loop is something you very rarely need to do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making an app where the user can set an alarm based on
Making an Flex App. Just wondering if anyone has created something that fits automatically
I'm making an Android app and need to use GPS for recording a drivers
I'm making an app which uses CoreLocation to provide GPS coordinates. The next thing
I'm making a GPS app that will deals with 200 millions records in a
I am making an app that allows the user to set an alarm based
Making a new site but something is happening to it in IE8. The social
Making a new site but something is happening to it in IE. I've purchased
Making UML sequence diagram in VS 2010RC I've observed that there is no activation
Making websites that appear correctly in IE is a big problem. Is there any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.