First Use Guide
Last updated
Last updated
svyPhonegap is a service to provide native mobile functionality from a Servoy application. This guide will help you integrate and build your first mobile app using the service.
Once you've gotten your main Servoy solution created, install the Phonegap Module. This is available under the Servoy Package Manager. Alternatively you can also download this module directly from our github repository.
Select your main solution and hook up the onOpen event to a new scope method.
You can also hook up a callback method if you need access to native functionality as soon as the device is ready. Your code might look like below
In this example we will integrate with the phone's native camera application. To get started first build a new form and add a label and a button. The button will start the phone's camera app and the label will be used to preview the image captured.
Hook up the button to an onAction event.
Notice that we are using the plugins.svyphonegap to access the API for this specific integration. For more detail please review our reference guide here.
This specific API requires you to have options and callback functions hooked up. In the code below we specify options such as which camera source (front/back) to use and also the quality of the image.
After you've captured the image, we have a callback (getPicSuccess) that will update our specific label (contact_photo). Using some HTML markup and the base64 data (res) received from the camera, we can then show a preview of the image to the user.
Once you are satisfied with the main solution and code. We will want to be able to export and run this app on a mobile device. First deploy the Servoy solution to a web server. Then follow the Building Native Binary guide.