Cordova 3 - iOs - navigator.connection未定义 [英] Cordova 3 - iOs - navigator.connection Undefined

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

问题描述

您好,我试图访问iOs设备上的连接没有任何成功...



我尝试按照这篇文章无论结果如何。



/ p>

  $ 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

并添加:

 < feature name =NetworkStatus> 
< param name =ios-packagevalue =CDVConnection/>
< / feature>文件中的

。我还尝试将功能行包装在< plugin>< / plugin> 标签,因为我不知道是否需要,

如果我从CLI运行: cordova插件列表



如预期: ['org.apache.cordova.network-information']



但我继续得到undefined如果我尝试警告连接类型(我检查,我在等待deviceReady事件)。关于如何解决这个问题的任何建议?



提前感谢!

解决方案

p>首先,为什么你会运行 $ cordova插件rm org.apache.cordova.core.network-information ?此操作会在您安装插件之后删除您的插件。不知何故,当然,根据 cordova插件列表插件已经安装了,所以让我们继续。



make确保所有插件文件在正确的位置。 cordova 3有习惯不将本机插件文件复制到平台文件夹中。您可能必须手动将插件的 src / [platform] 文件夹的内容复制到平台文件夹中的正确位置。对于ios,它将是 platforms / ios / [project name] / Plugins / [Plugin Name] 。在Android上它是像 platforms / android / src / org / apache / cordova / [plugin name]



你不必在config.xml中做任何事情,cordova会在您通过CLI添加插件时自动执行此操作。你可能需要手动做的唯一的事情是复制本地插件文件,如上所述。


Hi I'm trying to access connection on iOs device without any success...

I try to follow this post withot any result.

I run:

$ 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

and added:

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

in the config.xml file. I also try to wrap the feature lines in a <plugin></plugin> tag as I was not sure if it was needed, but nothing.

If I run from CLI: cordova plugin list

I obtain as expected: [ 'org.apache.cordova.network-information' ]

But I keep on getting undefined if I try to alert the connection type (I checked that I'm waiting the deviceReady event). Any suggestion on how to fix this?

Thanks in advance!

解决方案

first of all, why would you run $ cordova plugin rm org.apache.cordova.core.network-information? what this does is removing your plugin, right after you installed it. somehow, of course, according to cordova plugin list the plugin is installed anyway, so let's move on.

make sure all plugin files are in the right spot. cordova 3 has the habit to not copy the native plugin files into the platform folder. you might have to manually copy the contents of your plugin's src/[platform] folder into the correct place in the platform folder. for ios it would be platforms/ios/[project name]/Plugins/[Plugin Name]. on android it's something like platforms/android/src/org/apache/cordova/[plugin name].

you don't have to do anything in config.xml, cordova does this automatically when you add a plugin via CLI. The only thing you might have to do manually is copying the native plugin files as I described above.

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

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