Xcode PhoneGap navigator.connection Undefined

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

When i call:

navigator.connection.type 

I get 'undefined' for navigation.

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

Update: Currently, I only run 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!

+3
ios xcode cordova
source share
2 answers

I did my research on this issue and finally came up with a solution. Apparently, PhoneGap (Adobe) recently updated its documentation and filled the many holes I used for Phonegap 3.0.0

1) To do this, using the command line interface, you must install git in order to be able to run these commands. Get git here .

2) They added Connection plugins to the 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> 
+7
source share

If you just want to find out if you are connected or not, try using navigator.onLine in js instead. Works for me on iOS 8 and Android 2.3 and does not require any plugins

+2
source share

All Articles