Mobile Integrations

This is a guide for how to add hardware integrations for a servoy mobile app. Hardware integrations such as camera, fingerprint, audio, vibration and other various sensors.

Adding Phonegap Module

Start by adding the phonegap module to your solution. It's the foundation for all native device integrations. Go to the package manager to download and install. Once you've done that follow through the wiki to setup an onSolutionOpen hook event and initialize the module.

Integration with the camera

Integrating a mobile application with the camera on a smartphone is a common requirement. We can use the phonegap camera plugin to do this easily.

First setup a form to show a preview for the image that we will capture. Start by adding an label component for the image preview and a button to start the capture mechanism. Set the cssPosition properties for anchoring and style the form so that it can fit in a mobile viewport.

We will tie the onAction event to a method that will call the the phonegap plugin and start up the native camera on the device. This plugin's api takes a success method, failure method, and an options object as arguments. The success method will fire once the native camera app finishes capturing an image.

It contains an argument which is the base64 image data string when fired. We can use basic HTML markup to generate an image tag for the label component. For more details on this process review the camera plugin wiki.

Important remarks

In order to evaluate or execute the plugin we need still need to build a native binary. This is an important step to get the application to run, install on a smartphone/tablet and actually make use of the native camera.

Last updated