Search code examples
iosxcodeeventscordova

Deviceready event doesn't fire with phoneGap in Xcode


I'm using mac os lion with the latest xcode version. I installed phonegap from the official website (the 1.2.0 version), I saw the welcome message "phonegap is working". But I want to write files with the phoneGap API on the iOs simulator (version 4.3) and when I try to fire the "deviceready" event, it doesn't work at all.

Here is my code in 'index.html' :

<srcipt type='text/javascript'>
function fun(){
 alert("fired");
}
document.addEventListener("deviceready", fun, false);
</script> 

I can't see the alert. I really don't know why it doesn't work.


Solution

  • It works fine for me in a new PhoneGap project (although I had to change <srcipt type='text/javascript'> to <script type='text/javascript'>

    Could this typo have caused your issue?

    I added your code above (with the typo edited) to the <head> of the index.html page and upon running the project it popped up the expected alert.