Search code examples
javascriptandroidcordovaextjssencha-touch-2

Getting connection details in Sencha Touch fails: TypeError: Cannot read property 'type' of undefined


I am building an app using Sencha Touch 2. According to their documentation, and multiple other sources on the web (1, 2), I can get the connection type by using Ext.device.Connection.getType()

But on this line:

var connection = Ext.device.Connection.getType();

I get the following error on an Android device:

TypeError: Cannot read property 'type' of undefined

When running in Google Chrome on my desktop computer, it always returns null. Although, if I use the javascript console in Chrome to call Ext.device.Connection.isOnline(), this returns true, and getType() now starts returning 'Unknown connection' instead of null.

This is the relevant part of my config.xml (probably don't need all of these, but I have tried with only the two first and the two last, without changes):

<feature name="http://api.phonegap.com/1.0/device" />
<feature name="http://api.phonegap.com/1.0/geolocation" />
<feature name="Device">
    <param name="android-package" value="org.apache.cordova.device.Device" />
</feature>
<feature name="NetworkStatus">
    <param name="android-package" value="org.apache.cordova.NetworkManager" />
</feature>

All other Cordova functionality works as expected, so I believe the framework is installed correctly. What am I doing wrong, and/or what can I do to figure this out?


Solution

  • So, the answer was that I needed the following plugin: http://build.phonegap.com/plugins/626

    I had this plugin in my config.xml file, but it had disappeard from the plugins folder, probably due to the project moving from person to person. The solution was to remove this plugin and re-add it a couple of times (it didn't work the first time), and then everything worked again.