GPS Support - Customer Tracking

GPS Support for our application was provided by creating a Swift class using NSTimer and Core Location to find the location of the user every X seconds where X is the specified time interval. NSTimer is Swift's timer class in which a function can be called every time interval and Core Location how you access and use the GPS locator in the phone of the user to find out where they are in the world. The accuracy of the GPS reading is customizable and the accuracy of the GPS reading in our application is set to the highest possible accuracy as we are displaying a user’s current position every time interval on a MapKit view.

Application Persistence

Application persistence was implemented in our solution by installing and configuring FMDB - an Objective C wrapper for SQLite to store the workouts that the user has completed. In order to use Objective C code in Swift, you have to configure a bridging header file which is a file that points to the Objective C file that you would like to use in your project and converts it to Swift syntax.

Localization and Internationalization

Setting up internationalization and localization support for French, German and Italian in our application. This was completed by adding these languages to the application and selecting the Localisable.Strings file, the Quotes files as well as all of the story board files which created 3 different versions of each of these files (one for each language mentioned above). Localisation is achieved as Swift automatically knows the currency as well as date and time formats for a particular language. Localisation and internationalization can be tested by setting the language of the application through the simulator menu and then the storyboards version of that language will be displayed in the simulator.

MVC Implementation

Implementing a map view which would display all of the GPS location points that the application recorded while they were in their workout. In order for the GPS location points to be displayed on the map view, they needed to be cast as annotations which in turn needed to be passed to the map view to be displayed.

Platform Scripting

Researching Bash scripting and creating a bash script which would increment the build number of our application which was stored in the property list file.
The script first had to read the build number of application from the Info.plist file; increment the build number then work out the current date and time, format the date and time in the format of YYYYMMDDHHMM and then concatenate the build number and new date stamp. This new string in turn had to be joined to the version number and module number by a dot.

Writing a localization function in Swift

Creating a Swift function that would first check the user location and then work out whether to display the distance measurements in miles or meters based on their location. My Location Singleton class first got the current GPS location as soon as the user enabled permission and then called a reverse Geocoder which is a Swift class which can work out the location of a user in human readable form such as street, city, region, state and country. As the Geocoder is an asynchronous function call, a completion handler was implemented which would then contain the location as a return value and then depending on if the location used feet (US/Burma/ Liberia) the measurements of distance of the workout would be in feet or meters.

Installing Custom Logging Solution

Implementing a custom logging solution called XCGLogger and installing it via Cocoa Pods which is a framework dependency manager in Objective C and Swift. You can choose which dependencies that you would like your project to include by adding them to the Podfile in the project and then executing the pod file through Terminal. XCGLogger allows different levels of logging such as verbose, debug, error, warning and information and allows you to log to the console as well as a log file.

Working with Health Kit

Using the Health Kit API to ask the user to enable the required Health Kit permissions for our application. Health Kit is Apple's dashboard for managing all health data that a user inputs into their phone and data gathered from other devices such as the Apple Watch heart rate sensor. Apart from a heart rate, Apple records static data such as Gender, Date of Birth, Age, Blood type as well as dynamic data such as Heart Rate, weight, number of steps in last workout, time sleeping and sleep cycling as well as nutrition information. It is a place where all health data can be added, edited and updated in once place and it made available to developers through the Health Kit APIs. In order to first use Health Kit, you have to ask permission from the user for your application to write to and read from Health Kit for all of the permissions that your application needs.