DEVELOPERS BLOG

Not only can Sample Projects save time…they can save lives. Open source to the rescue!

Below is a post from Richard Balsewich (@OnlineODB)

If you have ever participated or competed in a hackathon, then you already know how much time you have to build something “real”… Not enough! So how can you turn the time-constraint in your favor? Easy… smart searching and open source and sample projects.

Dev1

So from the authors that brought you the epic series “From GitHub to Production”, we are back putting our approach to the test and showing you how sample projects can save time and even save lives. We just so happen to be at a hackathon that involved the need for disaster preparedness solutions, so as soon as the contest started this is what we came up with:

We imagined a solution that involved GeoFencing capabilities that can provide alerts/messages to a user on the location or area they just entered. For example, “Fire ahead turn around” or “Medical Supplies to the left after you enter building”.

There were several technologies and capabilities we would need to accomplish this solution, for any user on any platform. So our smart searching and sample project focus was broken down into the following:

  • mBaaS – “mobile Backend as a Service” – store and forward transactions
  • Device Capabilities – GPS and location based services for accuracy
  • Maps and Overlays – visualization and coordinates of Points of Interest (POIs)

mBaaS:

There are tons of providers in this category to choose from both paid and free. Since the BlackBerry 10 platform offers App and Content Management for Android devices as well as an Android runtime, we decided to go with Google Cloud due to their “ready-to-deploy” cloud service and sample project. The sample application we found demonstrates the JSON data object exchange between a mobile end-point and the cloud service. Using this sample we will have a persistent way to allow admin users to enter POIs, and a place for our mobile solution and users to query.

Device Capabilities:

There are several ways to obtain a user’s current position. For this project, we focused on getting this information from the device GPS receiver. This would give us the accuracy we needed, as well as the ability to adjust the speed in which the coordinates were obtained. Since our end project will be the result of stitching together several sample projects with mixed technologies, we ventured to Cordova Geolocation to accomplish getting the user position.

Maps and Overlays:

Now you’d think this feature would be our biggest focus and be the biggest time consumer… and you’d think wrong, because we know BlackBerry’s Jim Ing (@jim_ing ). A few months back, Jim gave a demonstration on a Geofencing project he has contributed to open source that uses HTML5 and leverages Leaflet maps.
If you have not seen this demo, stop reading immediately and click HERE now!

Final Results:

Now that we had all the pieces to our puzzle, it was time to figure out what and how to stitch these pieces together. We decided the best approach would be to get a skeleton of the data flow working between the cloud and end-points first. Since this was not our first rodeo, we quickly outlined data types, transport and persistence deployment best practices for our end-points.

Backend end result: We deployed the mobile application entity and object structures to the cloud platform. This gave us our handshake of JSON objects full of meta-data for application elements, user elements, and query elements between our end-points and cloud service. We generated some dummy user and POIs that we could use to get started on the end-points.

Next, we focused on the concept of native mobile applications communicating with embedded WebViews, the basis for Cordova. Since our mapping and overlay sample project leverages web technologies, we wanted a way to expand the JavaScript libraries without having to spend time writing additional Cordova plugins. Nearly every platform offers this sort of hybrid application approach. (e.g.: BlackBerry 10 , Android , etc.)

Application end result: For android, we leveraged the @JavaScriptInterface.

We built most of the core features like awareness logic, hardware interaction, local persistence, app/user state and communication layer using native methods into a base native project. Then, these methods were exposed to our JavaScript libraries to provide for a more dynamic mapping experience.

Next, we updated the Geofence sample project to interact with our native base project to capture user details and our POIs. Additional logic was created to show the POIs to the user on the Overlay as well as their current position in relation to those POIs. We added some Geofences around some of the key buildings to demonstrate how exact we could be with the Overlays.

The end result was an android application deployed through BlackBerry Enterprise Service 10 to an Android Nexus 5 smartphone running BlackBerry Secure WorkSpace for Android. The application accomplished passing objects back and forth between each user and the backend. It tracked all users of the application and their whereabouts in relation to the POIs (good and bad). Although we did not win the hackathon, combining these samples to create a fully operational multi-platform mobile application was worth the validation that open-source projects can save time and save lives.

Dev 3
Dev4

Geofences combined with user location awareness for addressing disaster preparedness only scratches the surface of what can be accomplished with these technologies and capabilities. What other user cases can you envision these capabilities being used? Maybe punch a digital time clock for employees as they enter the work geofence? Comment below! I’m looking forward to seeing all of your contributions!

BlackBerry

About BlackBerry

BlackBerry is an enterprise software and services company focused on securing and managing IoT endpoints.