Client side update
The client can now login, his token will be registered at the server. This is necessary to push notifications to the device. Every four minutes the GPS location of the device will be pushed to the server when the app is running, the app doesn’t have to run in the foreground it may also run in the background for this to work. I wanted to send the time when the emergency case was created with the notification, but I ran into a problem. The notification size became too large. So I had to implement a work around. When the device receives a notification it gets the emergency case id, with this id it can pull the additional information from the web service regarding the emergency case. The time of the emergency case is necessary because when you check the notification and so much time has passed that your help would be too late, an alert should be shown. It is implemented now as follows: Your route is shown first before checking if you would be too late. The checking is done based on the system timestamp minus the creation time of the emergency case, then I calculate the minutes necessary for you to travel over the calculated route (average speed 10 km/h), and when I add these two up you should still arrive within 10 minutes. If not, you get an alert message and you are redirected to the home page. But I faced a problem, I wanted to send the java.sql.timestamp with the json object. When receiving it looked something like: “Mar 6, 2014 9:00:47 AM”, when I tried to transform this string to an NSDate using a formatter using: “MMM d, yyyy, h:mm:ss a”, it crashed constantly, I tried some other format strings but none seemed to work. I debugged it, it crashed at the MMM, maybe some language settings or something, it didn’t recognize Mar as March. After losing lots of time searching the web for solutions and debugging it, I decided to do the following. In the web service remove the java.sql.timestamp and do the conversion there to a European format: “dd/MM/yyyy HH:mm:ss”. That worked like a sharm, too bad I had lost so much time on this simple thing.
Yet to be done is, deciding you are at the victim’s location and pushing it to the server. Also redrawing of the map. I will probably update the map every 10 meters or so, and recalculate the route, so if you go of track a correct route is still shown. Also when you have passed the AED, this destination should be removed from the route and you should only be navigated to the victim. Furthermore some debugging will be required and some alert views have to be added when you don’t have your GPS location tracking on or you don’t have internet access. Still a few things to do, I hope they do go smoother than these few things I did now.