Friday 13 May 2016

1.7 Third Iteration

For the third iteration I had to:

  • Develop a notification service.
  • Figuring out how the swap process will happen.
  • Discover technologies I may need in order to meet the requirements of this iteration.
Risks

The main risk associated with this iteration is lack of knowledge. I need to manage my time efficiently and make sure I do not spend too much time researching for information and not actual develop my project. 

Another risk is the complexity of a push notification. They are not easy to implement. If I cannot figure out how to create a push notification, I will need to rethink how my system will swap a shift.

Third Iteration:

The third iteration, I needed to redesign how a swap will take place in my system. Initially, when I began identifying some of the functionality of the system in iteration one, I thought that the process of a swap would consist of three parties, Employee1, Employee2 and HR. Emplpyee1 can see all the shifts relating to Employee2 and vice versa. However, this is where my problems began. Due to data protection laws, Employee1 can only see data relating to Employee1 and Employee2 can only see data relating to Employee2. This is an issue as the functionality that I designed heavily depends on users being able to see each-others data (ie Shift information). Therefore, I needed to redesign the system.


How the system will preform a swap is as follows:
  1. Employee 1 clicks on one of their own shifts that they wish to swap.
  2. A Push notification is sent to all users (who are suitable) that a shift is up for a swap.
  3. Employee 2 clicks on the notification which brings them to a list of all suitable shifts which they are eligible to swap with. It must be noted that only the shift information is displayed and not the Employee information.
  4. Employee 2 clicks the shift they want to swap with.
  5. They then select one of their shifts current shifts to swap.
  6. The swap then then gets stored stored in a database, waiting for HR to authorize the swap.
  7. Once the swap is authorize, the shift table gets updated and the swap is deleted from the DB.
The main hurdle in this iteration is the push notification. After extensive research, I continued to encountered a service called "Google Cloud Messaging". This service is second cloud database that acts as a middle man between your app and database. Each user is given a unique key from GCM which then is sent to the DB. Then, when a notification needs to be created and sent to X amount of users, the DB sends all the keys relative to the users to GCM which in turn then sents the notification to the users. Sounds complex? Its because it is!After many hours, I unsuccessfully managed to set up this service with my current project. I felt that it was time to move on the find a new solution to this problem. The solution however came from an unexpected resource.

To solve the issue, I turned back to Firebase. In iteration one I became familiar with Firebase as I was using it as my main back end service. One of the methods build into Firebase is called "OnChildAdded". This method is triggered when an item is added into the Firebase DB. I was able to incorporate this functionality to develop a push notification as follows:
  1. When a user wants to swap a shift, they push they shift they want to swap to Firebase.
  2. In Firebase, there is a generic "Shift" table. The shift in question is then added to the Firebase table.
  3. This in turn triggers the OnChildAdded method as the table has been updated. 
  4. When triggered, a notification is created and sent to all users notifying that a shift is as I call it "up for grabs".
  5. The user then can click into this notification and see all the information about the shift.
This method successfully created a notification. The only issues actually seem to be with the lifecycle of the notification. The user can only see notifications if the application is not in the "OnDestroy" cycle. Otherwise the user will receive them. Furthermore, occasionally the notification does not go when the user clicks into it. However, overall I am happy with what I have so for accomplished. The issues with the notifications I feel I will be able to solve over time. But because I am under time constraints, will suffice for now.

No comments:

Post a Comment