phonegap navigator.connection is undefined

百般思念 提交于 2019-12-08 20:46:13

问题


I've got a problem using Phonegap. I've created a Test application using console:

phonegap create ProjectTest

cordova platform add ios

cordova build

Then opened generated Xcode project and added new line to onDeviceReady function:

onDeviceReady: function() {
    app.receivedEvent('deviceready');
    // MY TEST
    alert(navigator.connection);      
}

Also i've added this line to my config.xml:

<plugin name="NetworkStatus" value="CDVConnection" />

So, result in alert is 'undefined'......

I just need to test the connection, using navigator.connection.type

Using MacBook and Xcode 4.6.3


回答1:


Same issue here. I was testing my code after these steps. create, add platform ios, add plugin blabla. When you do like this, its not working. You have to say

$ cordova build ios

or

$ phonegap build ios

after that, its creating new files about plugins and its working. Hope that help you too.

(cordova 3.3.0)




回答2:


I was having a similar issue, and was able to answer my own question after a bunch of research.

See this StackOverflow post for the solution.




回答3:


You should add connection plugin first



来源:https://stackoverflow.com/questions/17877397/phonegap-navigator-connection-is-undefined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!