cancel
Showing results for 
Search instead for 
Did you mean: 

PhoneGap with HWC

Former Member
0 Kudos

Hi All,

I'm using SUP version 2.1.3 and is trying to make use of PhoneGap functionality with a hybrid application. As I read through some information, version 1.4 of PhoneGap is already linked with this version of SUP and is ready for use. But when I'm trying to make some call to the geolocation api's or network for example, I'm not able to make calls to the relevant JS functions defined within the custom.js.

I would need your input in order to make it work. Awaiting your responses.

Thanks in advance.

Cheers,

Gourav

Accepted Solutions (1)

Accepted Solutions (1)

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

I believe you should be able to add the following code

alert(navigator.network.connection.type);

to a method such as customAfterShowScreen() ...

You need to be careful that you only call the phonegap methods after the phonegap library has fully loaded.  See

http://docs.phonegap.com/en/1.4.0/phonegap_events_events.md.html

The following sample may also be of use.

PhoneGap and Hybrid Web Container Customization Sample for 2.1 ESD #3  https://cw.sdn.sap.com/cw/docs/DOC-149428

As well, the following sample shows an alternative way to get the device's location.  See the section titled Getting the Device Location

Expense Tracking Sample https://cw.sdn.sap.com/cw/docs/DOC-148193

Former Member
0 Kudos

Hi Daniel,

Thanks for your response.

Yes I'm aware that we would need to call up the functions when phone gap is fully loaded and is using the onDeviceReady event.

I've also gone through the above links already and have placed a similar alert as above but initially it was not responding with anything but now it is giving a message saying Cannot read property "Connection" of undefined. Looks like it is not able to recognize the navigator.network object.

Further suggestions please.

Cheers,

Gourav

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

What mobile device or simulator are you using?  What is the version of the Hybrid Web Container on that device or simulator?

In SUP 2.1.3, phonegap support was added for Android and iOS only.  BlackBerry and Windows Mobile in SUP 2.2.

The 2.2 Hybrid Web Container is not compatible with the phonegap files generated from a 2.1.3 Eclipse tooling.

See

https://cw.sdn.sap.com/cw/message/98960#98960

Former Member
0 Kudos

Hi Daniel,

I'm using an Android simulator platform 4.2.2 with API level 17. And I've tried it on both the workflow & hybrid web container clients version 2.1.0 & 2.1.3 respectively. It doesn't seems to work in either.

Infact while testing in HWC client 2.1.3, I also get a message saying connection to the server was unsuccessful where as the same runs fine in 2.1.0 without this error but it is not able to make any call to the phonegap apis. Please find the screen shot below:

Cheers,

Gourav

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

What version of the Mobile Workflow (Eclipse) tooling are you using? 

The phonegap functionality was introduced in SUP 2.1.3, so you would need to generate your mobile workflow using the SUP 2.1.3 mobile workflow tooling and run it in a workflow container (also know as the Hybrid Web Container) that is version 2.1.3.

Former Member
0 Kudos

Hi Daniel,

I'm using Sybase Unwired Workspace version 2.1.3 as the IDE in order to generate the workflows if that is what you mean.

Any idea on the above error for the connection as that is what I'm getting for the 2.1.3 HWC client and I see it is not just occurring in any phonegap application but also any other hybrid app. I can think of it being related to the slow network @ my end or any other reason do you think?

Cheers,

Gourav

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

I don't recall seeing that particular error before.  I would start though by going to the settings screen of the workflow container and choose restart, and then choose show log.  If there are messages there showing a failure to connect, I would open up the device browser and enter http://ipNumberofSUPServer:5001.

I believe you should get a white screen if it succeeds. 

If that fails, try restarting the simulator.

If that works, but the log still shows a problem connecting, try deleting the application connection in SCC and recreating it, also on the device go Android Settings > Applications > Mobile Workflow > Clear Data and then refill in its settings making sure to use the ip address for the server name.

Let me know if that helps.

Dan

Former Member
0 Kudos

Hi Daniel,

The confusing thing is it is showing connected in the logs and even with the above url it shows a white screen successfully but it gives that connection error for all applications that I run. The same app is running fine in other AVDs with workflow container 2.1.0.

Cheers,

Gourav

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

What happens if you create a new workflow app that simply contains one screen?  Is this problem a general problem or specific to one app?

Another thing to try would be to check the Android log.  Perhaps a more useful message can be found there.

adb logcat

or

adb logcat > c:\out.txt

I suppose you could also try using an older Android version such as 2.2 (note Android simulator 2.3.3 does not work with the mobile workflow container).  Obviously 4.2.2 had not been created and tested with SUP 2.1.3 since it was recently released.

http://infocenter.sybase.com/help/topic/com.sybase.infocenter.dc01699.0213/doc/html/lly1336586165518...

Former Member
0 Kudos

Hi Daniel,

Currently I'm trying with very simple apps containing just 1 or 2 screens but the problem was with all apps. As per the link you gave above, I've downgraded to OS version 3.2 api level 13 with HWC container client after which I do not see that connection error any more. My Other apps are running fine now. But still the phonegap call is not working and is now giving the below error:

Please suggest.

Cheers,

Gourav

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

Here is the code I tried it with.  I used an Android 4.0.3 simulator and a 2.1.3 Hybrid Web Container.  Mine said it was version 2.1.3.6319.  What is the build number of your Hybrid Web Container?

function customAfterWorkflowLoad() {

    document.addEventListener("deviceready", onDeviceReady, false);

}

function onDeviceReady() {

    try {

        alert("PhoneGap 1.4.0 " + navigator.network.connection.type);

    }

    catch (e) {

        alert(e.message);

    }

}

Former Member
0 Kudos

Hi Daniel,

It is working now. Not sure why it gave me the evaluating error but the issue has been the version as you suggested above.

Thanks so much for your help.

Regards,

Gourav

Former Member
0 Kudos

Hi Daniel,

One more thing I would need to know. I was also testing the phonegap 1.4 (integrated with SUP 2.1.3) in an android 2.2 device with both workflow.apk & hybridwebcontainer.apk clients but it does not seems to work. Is it the android version which is the limitation or an issue with the .apk client? Which container would support phonegap 1.4?

Thanks in advance.

Regards,

Gourav

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

In my 2.1.3 install, the file name of the Hybrid Web Container is HybridWebContainer.apk.  Another way to verify the version is to go to the Hybrid Web Container's settings screen and choose the about menu item.

Glad it is finally working. 

Answers (0)