window.cordova not initializing in PhoneGap 2.2

316 views
Skip to first unread message

Thomas Anderson

unread,
Jan 7, 2013, 5:17:32 AM1/7/13
to phon...@googlegroups.com

I've recently upgraded to PhoneGap 2.2, and have upgraded from every version of PhoneGap since 1.4. Each time I basically download PhoneGap, install a new XCode project from scratch from the terminal, copy my files into www, tweak cordova.plist a little, copy cordova.ios.js into my scripts directory and point to it from my index file. No big deal, right?

This time around, however, I'm having problems. I am certain that cordova.ios.js is being included from my tag because I put an alert on line 1 and the alert fires when my app inits. If I then do the following, however:

alert(typeof window.cordova.exec);

.. I would expect to see "function". This time I'm getting an undefined error. Also, all calls to any PhoneGap specific functionality is failing. (Camera access, etc)

Is there anything special about Cordova/PhoneGap 2.2 compared to 2.1 that I am overlooking?

Shazron

unread,
Jan 7, 2013, 2:32:46 PM1/7/13
to phonegap
what does this return?

cordova.require('cordova/exec');


--
-- You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
 
For more info on PhoneGap or to download the code go to www.phonegap.com
 
To compile in the cloud, check out build.phonegap.com
 
 

Thomas Anderson

unread,
Jan 7, 2013, 8:33:55 PM1/7/13
to phon...@googlegroups.com
Hi Shazron,

I did three things per your hinting:

1)  I wrapped cordova.ios.js in a try/catch block and places alerts at both ends of the try.  Both alerts fired, letting me know the file is being included and isn't crashing.

2)  After in inclusion of cordova, I run  $(function() { document.addEventListener("deviceready", phonegapDeviceReady, false); }  I then put an alert in function phonegapDeviceReady().  It is never fired.

3)  I did "alert(cordova.require('cordova/exec'));" in my main app, wrapped it a try/catch block.  Nothing happens.

So overall it feels like deviceready is never firing.  The only difference I see between my  index.html file and the sample one included in Phonegap 2.2 is: In the sample index.html, it doesn't listen for deviceready until after <body onload=""> has fired.  In my code, I attach the listener immediately after including the javascript.  Just for giggles I commented it out and moved it to the top of my body's onload function, but it didn't make a difference.

Open for more hints..

Shazron

unread,
Jan 8, 2013, 6:18:33 PM1/8/13
to phonegap

Thomas Anderson

unread,
Jan 8, 2013, 6:38:41 PM1/8/13
to phon...@googlegroups.com
Great, thanks for the link!  I'll monitor that issue.  Glad I'm not going nuts..
Reply all
Reply to author
Forward
0 new messages