Whilst working at Touch Right I was asked to develop a lone worker feature that would allow users to send alerts to account owners from within the iOS and Android apps.
I worked with the directors of the company to spec the project, as the project would involve comprehensive updates to 5 applications (iOS app, Android app, Web Based app, API, Swagger) we consulted with an external development house to review the specification document so that they could provide any insight before the development process began. Once all parties were happy with the specification I started development on the Web Based app.
Web-Based app
As I was creating a new type of record of data it was important to ensure that this data could be represented in MYSQL, once the MYSQL script for creating a table named alerts was written it was time to test the script. I use HeidiSQL when doing anything MYSQL, I always write MYSQL to include columns that track the user, function, and timestamp of the last known time the record was created or updated. This helps with diagnosing issues that may pop up in the testing phase of the development process.
Once we have somewhere to store the data it’s now time to look at working with this data in the Web-Based app. I implement new factories, controller, and services to manage the backend processing of anything related to Lone Working. At this milestone it is now time to have my code reviewed, I then move on to implementing a new index.phtml page to display alerts to the user in a data table. Alerts were able to be configured from this view allowing users to assign amber or red alerts to certain contacts.
API & Swagger
Once I had completed work on the Web-Based app it was time to work on the API and Swagger documentation. First things first, I needed to configure new factories, controller, and services to manage the processing of anything related to Lone Working.
I decided that a single endpoint would need to be created to allow both Android and iOS apps to POST alerts. I created the model for alerts based on the database structure for the record as shown here.
Once the model was created it was time to implement the action in the AlertController.php file that would handle the POST functionality, within this action, I implemented numerous validation checks on the data included in the POST request. If the validations were passed then and only then would data be committed to the DB, if not then data would rollback.
Once testing was completed and any issues fixed it was time to update the Swagger documentation to include the Alert model and endpoint details.
iOS & Android apps
Both of the apps would need to be updated in similar ways to discreetly send alerts to predefined contacts. I started working on migrating the database to now include the alert record, once this was completed I started implementing the functions to handle the POST request.
I implemented 2 buttons, one for the amber alert and the other for the red alert. When pressed they would POST the latitude and longitude of the user to the Web-Based App which would then email the alert details to the predefined user.
Please click here to find out more about my implementation of the Lone Worker feature for Touch Right Software.