phonegap navigator.connection未定义 [英] phonegap navigator.connection is undefined
问题描述
我使用 Phonegap
时遇到问题。
我使用控制台创建了一个测试应用程序:
I've got a problem using Phonegap
.
I've created a Test application using console:
phonegap create ProjectTest
cordova platform add ios
cordova build
然后打开生成的Xcode项目并添加新的line to onDeviceReady function:
Then opened generated Xcode project and added new line to onDeviceReady function:
onDeviceReady: function() {
app.receivedEvent('deviceready');
// MY TEST
alert(navigator.connection);
}
我已经添加这行到我的config.xml:
Also i've added this line to my config.xml:
<plugin name="NetworkStatus" value="CDVConnection" />
因此,alert的结果是'undefined'......
So, result in alert is 'undefined'......
我只需要测试连接,使用 navigator.connection.type
I just need to test the connection, using navigator.connection.type
使用 MacBook
和 Xcode 4.6.3
推荐答案
同样的问题。我在这些步骤后测试我的代码。创建,添加平台ios,添加插件blabla。 不得不说
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
或
$ phonegap build ios
之后,它会创建有关插件的新文件,工作。希望也能帮助你。
after that, its creating new files about plugins and its working. Hope that help you too.
(cordova 3.3.0)
(cordova 3.3.0)
这篇关于phonegap navigator.connection未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!