Xcode PhoneGap navigator.connection未定义 [英] Xcode PhoneGap navigator.connection Undefined

查看:273
本文介绍了Xcode PhoneGap navigator.connection未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试将PhoneGap javascript代码移植到Xcode中以便在iOS中进行调试。
使用Cordova-3.0.0。



当我调用:

  navigator.connection.type 

我得到一个'undefined'navigator.connection。



我没有在我的config.xml中正确地包含网络连接插件,或者是别的什么东西?是的,我包括正确的cordova.js文件专门为iOS。是的,deviceready已被启动。



更新:我目前只在iOS模拟器上运行。



我的config.xml:

 <?xml version ='1.0'encoding ='utf-8'?& 
< widget id =com.app.testversion =0.0.1xmlns =http://www.w3.org/ns/widgetsxmlns:cdv =http:// cordova .apache.org / ns / 1.0>
< name> Hello Cordova< / name>
< description>
说明
< / description>
< writer email =dev@callback.apache.orghref =http://cordova.io>
Apache Cordova团队
< / author>
< access origin =*/>
< preference name =fullscreenvalue =true/>
< preference name =webviewbouncevalue =true/>
< plugins>
< plugin name =NetworkStatusvalue =CDVConnection/>
< / plugins>
< / widget>感谢您的帮助!



< >解决方案

我做了我的研究,最后想出了解决方案。
显然PhoneGap(Adobe)最近更新了他们的文档,并填写了很多我正在进入Phonegap 3.0.0的漏洞



1)这使用命令行界面,你必须安装git才能运行这些命令。请点击此处



2)他们添加到连接插件文档,以使用以下命令行界面命令将插件添加到项目中:

  $ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin -network-information.git 
$ cordova plugin rm org.apache.cordova.core.network-information

3)他们将config.xml文件中的声明更新为以下(对于iOS):

  feature name =NetworkStatus> 
< param name =ios-packagevalue =CDVConnection/>
< / feature>


Trying to port my PhoneGap javascript code into Xcode for debugging in iOS. Using Cordova-3.0.0.

When I call:

navigator.connection.type

I am getting an 'undefined' for navigator.connection.

Did I not include the network connection plugin correctly in my config.xml, or is something else amiss? Yes, I included the correct cordova.js file specifically for iOS. Yes, deviceready has been fired.

Update: I am currently only running this on the iOS emulator.

My config.xml:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.app.test" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>Hello Cordova</name>
    <description>
        Description
    </description>
    <author email="dev@callback.apache.org" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <access origin="*" />
    <preference name="fullscreen" value="true" />
    <preference name="webviewbounce" value="true" />
    <plugins>
        <plugin name="NetworkStatus" value="CDVConnection" />
    </plugins>
</widget>

Thank you for your help!

解决方案

Been doing my research on this one, and finally came up with the solution. Apparently PhoneGap (Adobe) recently updated their documentation, and filled in a lot of the holes I was running into for Phonegap 3.0.0

1) To do this using the command-line interface, you have to have git installed to be able to run those commands. Get git here.

2) They added to the Connection plugin documentation to use the following command-line interface commands to add the plugin to the project:

$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information.git
$ cordova plugin rm org.apache.cordova.core.network-information

3) They updated the declaration in the config.xml file to the following (for iOS):

<feature name="NetworkStatus">
    <param name="ios-package" value="CDVConnection" />
</feature>

这篇关于Xcode PhoneGap navigator.connection未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆