Sending info between Servoy app and Phonegap Build app

Questions and answers on developing, deploying and using plugins and JavaBeans

Sending info between Servoy app and Phonegap Build app

Postby Thomas.shuttleworth » Mon Jun 19, 2017 5:01 pm

Hi,

I've currently got a Servoy application on which i'd like to implement a camera function. I've been working with Phonegap Build to build an app there which will call my Servoy app in an iframe so that I can use the Phonegap plugins, specifically the camera one. I've read elsewhere on the forum that I need a bridge to send information between the Phonegap build app and Servoy and I downloaded a copy of the svyMobile example on Github but am not having much luck in getting that work either. The Servoy apps open in the iframe but when I interact with the buttons, the BlockUI, linked to the buttons, runs indefinitely which indicates to me that the Phonegap plugin isn't running. I was hoping someone could explain what I need to run the Phonegap camera plugin, in Servoy, through an iframe, in Phonegap Build.

I'm testing the app built by Phonegap build on an Android virtual device and also a physical Android phone.

I've heard last weeks webinar covers phonegap plugins somewhat and i'll be sure to check that out when the recorded version is online but if anyone can help before then, that would be great.

Thanks
Thomas.shuttleworth
 
Posts: 24
Joined: Wed Apr 05, 2017 5:08 pm

Re: Sending info between Servoy app and Phonegap Build app

Postby vschuurhof » Thu Jun 22, 2017 9:55 am

Hi Thomas,

Just to give you a bit of context of what this module does:

The "index.html" is a page that runs locally on the mobile device. And this page has direct access to local resources such as the camera. The actual NG Client solution runs inside an iframe of that local page but doesn't have direct access. This is the reason why we have developed a bridge which has a client-side (the device) and a server-side version (the Servoy solution). All it basically does is enabling communication between the two. So if you would like to access the camera from the solution, you would call the "svyphonegap-camera" service, which will dispatch that call from the "server" bridge to the "client" bridge so it can be executed locally from that "index.html" page. Both bridges are also responsible for handling the return value (the image in this case) so it will come back to the solution.

The main reasons why it wouldn't work would be:

- The client-side bridge is not properly initialized within the "index.html" page.
- The whole PhoneGap functionality is not initialzed from within that same page (it needs to be included like this "<script src="phonegap.js"></script>").
- The camera plugin is not included in the "config.xml" which PhoneGap needs to build the app.
Vincent Schuurhof
Servoy
vschuurhof
 
Posts: 69
Joined: Tue Dec 14, 2010 12:00 pm

Re: Sending info between Servoy app and Phonegap Build app

Postby Thomas.shuttleworth » Thu Jun 22, 2017 10:40 am

Thanks for letting me know a little more about what each bit does! I've been using a version of bridge.js I got from the svyMobile app I found on github, which I also can't get to run. Would building another bridge, that is more tailored to my project, help towards connecting the Servoy and the Client?
Thomas.shuttleworth
 
Posts: 24
Joined: Wed Apr 05, 2017 5:08 pm

Re: Sending info between Servoy app and Phonegap Build app

Postby vschuurhof » Thu Jun 22, 2017 11:07 am

Building a custom bridge is something I highly discourage! I don't know if you have seen the code inside, but it's quite complex and you need to understand a lot about how to debug each step within the communication plus how to use all the debug tools. I believe that the current bridge gives you everything you need.

So, what happens now if you call the camera plugin? Can you please elaborate on that?
Vincent Schuurhof
Servoy
vschuurhof
 
Posts: 69
Joined: Tue Dec 14, 2010 12:00 pm

Re: Sending info between Servoy app and Phonegap Build app

Postby Thomas.shuttleworth » Thu Jun 22, 2017 11:18 am

Well I must admit, i've seen the contents of the bridge and was fairly worried about having to build one myself!

As far as the plugin's response in the app, i'm not getting any response. I added an application output in the servoy code which outputs the results of the plugin call. So far, all i've recieved from that is <null>.
Thomas.shuttleworth
 
Posts: 24
Joined: Wed Apr 05, 2017 5:08 pm

Re: Sending info between Servoy app and Phonegap Build app

Postby vschuurhof » Thu Jun 22, 2017 11:40 am

Ok, and are you able to take a picture on the device? Or does that also fail?
Vincent Schuurhof
Servoy
vschuurhof
 
Posts: 69
Joined: Tue Dec 14, 2010 12:00 pm

Re: Sending info between Servoy app and Phonegap Build app

Postby Thomas.shuttleworth » Thu Jun 22, 2017 11:44 am

Just using the camera i'm able to take a picture but when I try to call the camera from the Servoy app it, the plugin comes up null. This led me to believe it was a problem with communictions between the device and Servoy which, from what you've said, sounds like a bridge issue
Thomas.shuttleworth
 
Posts: 24
Joined: Wed Apr 05, 2017 5:08 pm

Re: Sending info between Servoy app and Phonegap Build app

Postby vschuurhof » Thu Jun 22, 2017 12:23 pm

The result of the call to the camera is always "null" because calling stuff through the bridge is asynchronous. Every return value you would like to use in conjunction with the bridge can only be done by using callback methods.

But the fact that the camera is not started from that call seems strange. Let me take this up with Tuan (as he has been commiting on this project) and come back to you.
Vincent Schuurhof
Servoy
vschuurhof
 
Posts: 69
Joined: Tue Dec 14, 2010 12:00 pm

Re: Sending info between Servoy app and Phonegap Build app

Postby Thomas.shuttleworth » Thu Jun 22, 2017 12:34 pm

Thanks, I appreciate it
Thomas.shuttleworth
 
Posts: 24
Joined: Wed Apr 05, 2017 5:08 pm

Re: Sending info between Servoy app and Phonegap Build app

Postby rafig » Tue Jan 30, 2018 11:41 pm

Hi.
I am trying to get the 'svyMobile' latest demo solution to work with PhoneGap but nothing is appearing in the iFrame when I try and view it on my iPhone using the new PhoneGap Mac app http://docs.phonegap.com/references/desktop-app/install/mac/ & iOS client.
Please can more information and/or actual working copies of the
index.html
config.xml
files required to get the Servoy sample to work be posted either here or added to the Wiki page (https://github.com/Servoy/svyMobile/wiki)
so that we all have a good starting point (or if someone that has managed to get it working do so, please)
I'm sure that with a little bit more information & sample files for the app project folder we can all create some great 'hybrid' solutions
(and I think the code to initialise phonegap is now <script type="text/javascript" src="cordova.js"></script>)
Thanks
Rafi
Servoy Certified Developer
Image
rafig
 
Posts: 704
Joined: Mon Dec 22, 2003 12:58 pm
Location: Watford, UK


Return to Plugins and Beans

Who is online

Users browsing this forum: Bing [Bot] and 8 guests