How To Track Manifest Changes |
This document will highlight how to maintain up-to-date manifest on devices without push notifications or for users that do not have push notifications enabled.
Tip |
---|
Your app should always allow the user to manually perform a full manifest update. The standard way to do this is with a pull to refresh gesture. |
Note |
---|
All times referenced in this document are stored as Unix timestamp. Use epochconverter.com to convert human-readable dates and vice versa. |
Keeping the driver's manifest up-to-date with the server is important to maintain trust in the app. When the manifest changes, the driver should know in less then 30 seconds. This call is very lightweight and fast. It can be called every 10-15 seconds without performance concerns.
Check for changes
Refresh manifest from server
Mark changes as collected
Note |
---|
The token and device are obtained when logging into API |
Send a GET request to:ManifestChanges(String, String, String)
Note |
---|
For a smaller dataset, use ManifestChangesSlim(String, String, String) |
1var url = $"{storedRESTUrl}/TripService/Trips/ManifestChanges?Token={token}&Device={device}&Timestamp={timestamp}"; 2using (WebClient client = new WebClient()) 3{ 4 string s = client.DownloadString(url); 5 var token = JsonConvert.DeserializeObject<ListResponse<ManifestChange>>(s); 6 7}
It will return back a ListResponseT of ManifestChange with information about manifest changes that will look like:
{ "errorMessage": "", "success": true, "tokenExists": true, "tokenIsValid": true, "list": [{ "collected": false, "driverId": "timhibbard@engraph.com", "message": "Manifest change: JESSICA BOLSTER 10:31 PM PU 10:50 PM DO", "timestamp": "1571106053", "tripId": "33649" }, { "collected": false, "driverId": "timhibbard@engraph.com", "message": "Removed Kaye Smith 10\/16\/2019 8:00 AM PU from manifest", "timestamp": "1571275497", "tripId": "33683" }] }
Once we know a change exists on the server, there are several ways we can update our driver's manifest. The easiest way is do do a full refresh. There is also a more surgical approach if bandwidth preservation is a must.
Send a GET request to:TripsInWrapper(String, String, String, String, String, String)
Note |
---|
The TripIds parameter is a comma seperated string of TripId (i.e. "31154,2354,9854") |
Send a GET request to:TripDetails(String, String, String)
1var url = $"{storedRESTUrl}/TripService/TripDetails?Token={token}&Device={device}&tripids={tripIds}"; 2using (WebClient client = new WebClient()) 3{ 4 string s = client.DownloadString(url); 5 var token = JsonConvert.DeserializeObject<ListResponse<Stop>>(s); 6 7}
Once the data has been refreshed in your app, you need to let the server know you have processed the changes. This prevents unecessary server hits.
Send a GET request to:ManifestChangesMarkAsCollected(String, String, String)
1var url = $"{storedRESTUrl}/TripService/Trips/ManifestChangesProcessed?Token={token}&Device={device}&Timestamp={timestamp}"; 2using (WebClient client = new WebClient()) 3{ 4 string s = client.DownloadString(url); 5 var token = JsonConvert.DeserializeObject<SimpleResponse>(s); 6 7}
It will return back a SimpleResponse indicating if the operation was successful that will look like:
{ "errorMessage": "", "success": true, "tokenExists": true, "tokenIsValid": true }