Phonegap HTML app and various alerts hang browser
Asked Answered
D

3

47

When testing phonegap app, I get the following three alerts and the browser just hangs. Running app from server. Many times these alerts popup before the Ripple plugin can start. How do I remove these.

Alert 1:

gap:["Device","getDeviceInfo","Device818329805"]

Alert 2:

gap:["NetworkStatus","getConnectionInfo","NetworkStatus818329806"]

Alert 3:

gap:["App","show","App818329807"]
Derrik answered 4/6, 2013 at 14:35 Comment(2)
I'm having the same problem testing my app with ripple. the problem occurs for me even after the application is loaded.. and event like navigator.camera.getPicture trigger error like gap:["Camera","takePicture","Camera634184847"]Aigneis
Related question: #23633409Choiseul
R
32

If you're testing your app in your desktop browser, you can simply exclude the file. For Chrome:

<script type="text/javascript">
    if (!navigator.userAgent.toLowerCase().match('chrome')) {
        document.write("<script src='phonegap.js'><\/script>");
    }
</script>

(This way you don't have to remember to uncomment the script link for your build process.)

Roberge answered 21/8, 2013 at 7:44 Comment(1)
Thank you for this. I searched everywhere for this and it's been driving me nuts.Carniola
C
27

Those alerts normally show up when you have the wrong cordova.js file included. There are different ones for each platform. Make sure that you havn't for example copied the android one into your ios build.

Countable answered 4/6, 2013 at 14:42 Comment(4)
I was actually running it locally in a browser and not on the phone.Derrik
That will be the cause then ;) In the browser you can just click cancel on the 3 popups or alternatively comment out the cordova.js file while testing on the browser (just remember to uncomment it when you deploy to a device). Edit: just noticed you mention ripple (not sure how I missed that), I'm not sure how it will affect ripple.Countable
Yeah the problem is that sometimes they appear before ripple which is extremely annoying. Is there a better way to locally test mobile type functions in a browser prior to putting it on a device?Derrik
Not really, I normally do my testing of mobile functions with an android device as it's quick to deploy and test. For ripple you could perhaps try placing your javascript includes at the bottom of the html file (i.e. not in the header) and it might help with the loading of ripple issue.Countable
S
8

You just need to comment out this line on cordova.js :

return prompt(argsJson, 'gap:'+JSON.stringify([service, action, callbackId]));

which is on line 4184 when using Phonegap 2.9.0-0 (Android)

Uncomment before deploying to the device for production

Smarmy answered 30/7, 2013 at 15:58 Comment(1)
+1 - This was relevant for me using Cordova 4.1.1, there were 3 other prompt('s lurking in that file which I commented out, everything is working as expected now. Still none the wiser as to why cordova.js doesn't update with the platform.Hang

© 2022 - 2024 — McMap. All rights reserved.