Test energy efficiency

Because Plot keeps receiving the location of your device in the background you must ensure that your application stops doing work in the background. Tasks you need to look out for are timers that are scheduled repeatedly and subscriptions on location services.

Before you start a task ensure that your application is in the foreground. Note, when your app starts it may stay in the background. Don't assume it directly moves to the foreground. To check that your app is in the foreground, or your app starts and will move to the foreground can be done with: application.applicationState != UIApplicationStateBackground. IOS provides notifications which inform you when the app moves to the background, so you can pause the tasks when the app transitions to the background. There's another notification that informs when the application moves back to the foreground.

[[NSNotificationCenter defaultCenter] addObserver:self
[[NSNotificationCenter defaultCenter] addObserver:self

When your app makes use of MKMapView in a view that is directly loaded when your app starts and has the option "Shows User Location" enabled, then your app starts using GPS when it starts. Even when it starts in the background. You need to enable that option programmatically after the view did appear instead of directly when the view loads.

XCode comes with a tool called Instruments that shows multiple metrics related to power usage. Instruments can be found in the XCode menu behind "Open Developer Tool". The tool you need here is "Energy Log".

XCode > Instruments

Energy Log

It shows among other things how much of the CPU it utilizes and whether GPS is enabled. Keeping GPS enabled in the background really reduces battery life.

Energy Log Detailed

An important use case to test is what happens when your application starts in the background. The easiest way to trigger this is to start your app, allow location services and then restart your iPhone. Your app then starts with Plot in the background.