IPhone App Internals
Overview
The application is a standard iPhone application, which makes use of the Core Location framework to gather location information and store it in an array. This array is then turned into a JSON object and uploaded.
The location information is stored as an array of CLLocation objects. The initial item in the array at index 0 is a NSDictionary used to store statistics about the commute as well as the status. This array is then stored inside another array, each item representing a different commute.
Application Design
NB: the class prefix for all classes used in the application is 'CO2'.
The overall UI design can be followed by looking through the Main.storyboard file. The RootViewController is the main View Controoler which is loaded on app startup. From here you can navigate to the settings view, (SettingsViewController) the about page which is just a normal ViewController and a view that shows all the recorded commutes on the device, MyCommutesViewController. This list is a UITableView populated on load from the array of stored commutes, and tapping a commute will load a CommuteMapViewController which will show the commute on a MapKit view.
The AppDelegate is responsible for loading the main ViewController, and responds to system events such as detecting when the app is placed into the background, when it returns to the foreground etc. The AppDelegate creates an instance of LocationController when first opened, and this then manages the LocationRecorder object, creating it from scratch if no saved version exists, or loading the saved version from storage if it does. It is this object that contains the recorded commutes, as well as providing access to them. The LocationController also handles uploading the stored commutes, when this is started a background task is initiated that handles uploads.
API
The app will communicate with any endpoint configured to accept HTTP POST requests, and will attempt to send a JSON array representation of the commute data to the URL specified in the app's settings. The user name and password are used to authenticate to the remote server using HTTP Basic Access Authentication.
When working with a locker it uses the push endpoints which allows the push of any JSON object. For more information on this see Locker Push API