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: 22
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: 66
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: 22
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: 66
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: 22
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: 66
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: 22
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: 66
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: 22
Joined: Wed Apr 05, 2017 5:08 pm


Return to Plugins and Beans

Who is online

Users browsing this forum: No registered users and 2 guests