0

I am downloading the data at background from server in an offline app, where the data will be downloaded when the app launches for the first time .Later the app will be used as offline app.

I need to place the condition to check whether the data couldn't be downloaded due to low battery, Network issues etc.

Where Can I handle these in app life cycle?

1
  • show some code how you are doing the download, what API's are you using? your best bet will probably be in the appDelegates applicationDidEnterBackground and applicationWillTerminate Commented Nov 14, 2014 at 7:40

1 Answer 1

0

You can check [[UIDevice currentDevice] batteryState] if device is charging

UIDeviceBatteryStateUnknown,
UIDeviceBatteryStateUnplugged,   // on battery, discharging
UIDeviceBatteryStateCharging,    // plugged in, less than 100%
UIDeviceBatteryStateFull,        // plugged in, at 100%

Also you can get battery level via [[UIDevice currentDevice] batteryLevel] and decide to download content or not.

Note that batteryLevel is not so accurate, it rounded to 0.5
If you need more accurate measurements have a look https://github.com/nst/BatteryChart

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.